question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v5] Numerous issues with a fresh create-react-app install

See original GitHub issue

Using 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

  1. 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:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
vzaidmancommented, Sep 20, 2020
0reactions
vzaidmancommented, Sep 14, 2020

thanks for the report. will be fixed in beta. i know what’s the issue there. meanwhile please use 4.3.1

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found