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.

Library doesn't seem to work with NextJS.

See original GitHub issue

What I did:

  1. npm install @welldone-software/why-did-you-render --save --dev

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

github_iconTop GitHub Comments

2reactions
vzaidmancommented, Jan 3, 2021
1reaction
vzaidmancommented, Jan 10, 2021

I suggest moving it to another file. It might work now, but it doesn’t cover some cases which might break it.

Read more comments on GitHub >

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

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