Code Monkey home page Code Monkey logo

Comments (5)

Hypnosphi avatar Hypnosphi commented on May 16, 2024

It throws following exception:

TypeError: Cannot set property 'props' of undefined
    at Component (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:267013:14)
    at WithState (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:269148:33)
    at WDYRWrappedByMemoFunctionalComponent (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:83010:12)
    at renderWithHooks (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:233595:18)
    at updateFunctionComponent (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:235284:20)
    at updateSimpleMemoComponent (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:235230:10)
    at updateMemoComponent (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:235149:14)
    at beginWork (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:236346:16)
    at performUnitOfWork (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:239969:12)
    at workLoop (http://localhost:6006/vendors~main.317c2c034316233265a1.bundle.js:240009:24)

The reason is that WDYRWrappedByMemoFunctionalComponent calls the component as a function while in fact it is a class

from why-did-you-render.

vzaidman avatar vzaidman commented on May 16, 2024

ok i might indeed fix it. and maybe even soon but React.memo is made for functional components:
https://reactjs.org/docs/react-api.html#reactmemo

are you sure it even makes your class component pure?

from why-did-you-render.

Hypnosphi avatar Hypnosphi commented on May 16, 2024

Yeah I'm pretty sure: https://github.com/facebook/react/blob/master/packages/react-reconciler/src/__tests__/ReactMemo-test.internal.js#L222

from why-did-you-render.

vzaidman avatar vzaidman commented on May 16, 2024

added a prove that this happens (a test that fails) to the following branch:
https://github.com/welldone-software/why-did-you-render/tree/%2350-memo-a-class-component

Looks like a not too hard thing to fix, if anybody wants to try to do it.

from why-did-you-render.

vzaidman avatar vzaidman commented on May 16, 2024

fixed in https://github.com/welldone-software/why-did-you-render/tree/v3.3.4

from why-did-you-render.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.