Library doesn't seem to work with NextJS.
See original GitHub issueWhat I did:
-
npm install @welldone-software/why-did-you-render --save --dev
-
Added the following to
_app.js
:
if (process.env.NODE_ENV === 'development') {
if (typeof window !== 'undefined') {
const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React, {
trackAllPureComponents: true,
});
}
}
My component:
import React from 'react'
import { Container, Row, Col } from 'react-bootstrap'
const Header = () => {
const [counter, setCounter] = React.useState(0)
return (
<Row className='my-3 py-5' style={{ backgroundColor: 'pink' }}>
<Col align='center'>
<div onClick={() => setCounter(counter + 1)}>THIS IS THE HEADER {counter}</div>
</Col>
</Row>
)
}
Header.whyDidYouRender = true
export default Header
Clicking updates the counter
, however the library doesn’t log anything.
I do see a few logs for another component though (slider from react-slick
)
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
ReactJS Library being used in NextJS project says is not a ...
Does this answer your question: Import ES module in Next.js ERR_REQUIRE_ESM? Try adding "type": "module" in your library's package.json .
Read more >How to Import Browser Only Libraries Into Your Next.js ...
In this video we'll learn how to import browser only libraries into your Next.js apps. React has traditionally been a SPA framework that ......
Read more >module-not-found - Next.js
pages/index.js // Redis is a Node.js specific library that can't run in the browser // Trying to use it in code that runs...
Read more >Get Started with Next.js – The React Library Your Project Needs
What Features Next.js Gives You; What Features Next.js Doesn't Have ... The first reason for you to use Next is, as the banner...
Read more >Next.js Setup | ESLint Jest React Testing Library and Absolute ...
Linting means no need to worry that a missing ) or } will leave you bashing your head against the wall for 30...
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
I also improved the example on next.js: https://github.com/vercel/next.js/tree/canary/examples/with-why-did-you-render
I suggest moving it to another file. It might work now, but it doesn’t cover some cases which might break it.