[v5] Numerous issues with a fresh create-react-app install
See original GitHub issueUsing create-react-app 3.4.1 (which results in react 16.13.1)
Setting up
$ create-react-app --typescript testapp
...
$ cd testapp
$ yarn add --dev @welldone-software/why-did-you-render
I updated index.tsx
to read:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
//////////////// ADDED THIS
if (process.env.NODE_ENV === 'development') {
const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React, {});
}
//////////////// UP TO THIS
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
I updated App.tsx
to read:
import React, { useState } from 'react';
function App() {
const [whatever, setWhatever] = useState(1);
const clickme = () => {
setWhatever(whatever + 1);
}
return (
<div>
<button onClick={clickme}>test</button>
<div>{whatever}</div>
</div>
);
}
export default App;
Expectations
- I expect WDYR to work if I add
trackHooks: true
and either of:
1.1. Add App.whyDidYouRender = true
before the export default App
line
1.2. Add trackAllPureComponents: true
and change export default App
to read export default React.memo(App)
What actually happens
Both 1.1 and 1.2 produce no logs
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
We no longer support global installation of Create React App
npx create-react-app@4.0.3 your-new-app · Get above error, app not created. · Try removing global install as per the given instructions with npm ...
Read more >reactjs - Error while creating new react app (You are running ...
1 Answer 1 ; npm uninstall -g create-react-app; yarn global remove create-react-app. Then clear cache using one (or both) ; npx clear-npx-cache ...
Read more >STOP Using Create React App - YouTube
Create React App is a plague and we're here to cure it. Please use Vite, NextJS, or Remix instead. Seriously, anything is better...
Read more >Create React App v5 has been released : r/reactjs - Reddit
The install is kinda broken atm. You need to explicitly do 'npx create-react-app@5.0.0 [app name]' or use node 14.18.2.
Read more >create-react-app - npm
This package includes the global command for Create React App. Please refer to its documentation: Getting Started – How to create a new...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fixed in
5.0.0-alpha.4
thanks for the report. will be fixed in beta. i know what’s the issue there. meanwhile please use 4.3.1