Install Locator on React codebase. This is DevTools variant which is preffered solution. Alternative is data-id solution.
npm install -D @locator/runtimeAdd this to pages/_app.jsx (or other global file):import setupLocatorUI from "@locator/runtime";
if (process.env.NODE_ENV === "development") {
setupLocatorUI();
}
npm install -D @locator/webpack-loaderimport type { NextConfig } from "next";
const nextConfig: NextConfig = {
turbopack: {
rules: {
"**/*.{tsx,jsx}": {
loaders: [{
loader: "@locator/webpack-loader",
options: { env: "development" }
}]
}
}
}
};
export default nextConfig;module.exports = {
webpack: (config, { isServer }) => {
if (!isServer) {
config.module.rules.push({
test: /\.(tsx|ts|jsx|js)$/,
exclude: /node_modules/,
use: [{
loader: '@locator/webpack-loader',
options: {
env: 'development'
}
}]
});
}
return config;
}
};{
"presets": ["@babel/preset-react"],
"plugins": [
"@babel/plugin-transform-react-jsx-self",
"@babel/plugin-transform-react-jsx-source"
]
}