Coder Social home page Coder Social logo

Comments (2)

danswick avatar danswick commented on June 15, 2024

The listener was attached and removed in those lifecycle events (47019f3#diff-fae640c3677d082e033cc3beb0c626ceL72), but I moved them per this comment #60 (comment). Maybe I put them in the wrong place, but my read on that comment was that the listeners should not be attached or removed inside componentDidMount and componentWillUnmount anymore. If there's a way to address that comment without moving out of those two lifecycle events, I could use some help implementing.

from mr-ui.

davidtheclark avatar davidtheclark commented on June 15, 2024

Sorry, I meant componentDidUpdate ... 🤦‍♂️

In componentDidUpdate we'd say "Was the menu previously closed but is now open? If so, attach an event listener. Was the menu previously open but is now closed? If so, detach the event listener." And in componentWillUnmount we'll always detach the event listener — this change we should make regardless. This way we'd avoid triggering side effects from the render method.

That said, the other alternative to consider is keeping the event listeners where they were (attach only on mount, detach on unmount) but only having one test case.

from mr-ui.

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.