Category : create-react-app

I’ve wondered why my project takes too long, I’ve checked some topics about it, now I think that it maybe is the eslint cache problem in react-scripts. This is the result of TIMING=1 eslint . Rule | Time (ms) | Relative :—————————————-|———-:|——–: react/no-direct-mutation-state | 1818.923 | 24.9% react/no-typos | 812.661 | 11.1% react/require-render-return | 765.499 ..

Read more

With webpack 3, I was using moment-timezone-data-webpack-plugin to reduce my bundle size and it worked well. Tests showed it reduced the bundle size dramatically. I’ve now upgraded to webpack 4 and create-react-app 4, and it seems like this plugin has no impact on the total bundle size analyzing the bundle, moment-timezone only takes about 7k ..

Read more

I have just created a create-react-app project and it gave an error at first run, i did not modify anything the error: ./src/index.js 1:72 Module parse failed: Unexpected token (1:72) File was processed with these loaders: * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js * ./node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of these loaders. > $RefreshRuntime$ ..

Read more

I am revisiting an earlier idea to toggle between two buttons conditionally in a CRA. Tried wrapping the conditions in ternary/brackets {this.state.num < 8 ? div … btn1 … /div : div … btn2 … /div} as well as separately {this.state.num < 8 && div … btn1 … /div} both methods did not work and ..

Read more

I want to pass the VERCEL_GIT_COMMIT_REF variable to my javascript bundle. I’ve deployed Sanity in Vercel and it only passes variables with the prefix SANITY_STUDIO_. So, I’ve created an environment variable named SANITY_STUDIO_VERCEL_GIT_COMMIT_REF and want to pass VERCEL_GIT_COMMIT_REF into it. I tried a few ways but it doesn’t seem to work! Here is what I ..

Read more

I am using this method to inject server data. https://create-react-app.dev/docs/title-and-meta-tags#injecting-data-from-the-server-into-the-page window.SERVER_DATA = __SERVER_DATA__; Is there a way to set this variable before react application starts when using yarn start? The following example works but has some problems. try { window.SERVER_DATA = __SERVER_DATA__; } catch (err) { window.SERVER_DATA = { dummy: "data" } } The dummy ..

Read more

Unfortunately, I failed to create the react app projects using npx create-react-app signup_react But I had made various projects using this same command. I need help to solve this issue and the error is given below, Creating a new React app in /media/imdadul/PERSONAL/Professional Works/React_Projects/signup_react. Installing packages. This might take a couple of minutes. Installing react, ..

Read more

I cannot access environment variables dynamically in NextJS. In .env.local I have: NEXT_PUBLIC_TEST=test In _app.tsx I have: const test = "NEXT_PUBLIC_TEST"; console.log(process.env.NEXT_PUBLIC_TEST); // = ‘test’ console.log(process.env[test]); // = undefined I tried the same thing in Create React APP: # .env const test = ‘REACT_APP_TEST’ console.log(process.env.REACT_APP_TEST) // = ‘test’ console.log(process.env[test]) // = ‘test’ Does anybody know ..

Read more