Change in 1.8.2 causes calls to onStateChange even if state has not changed
See original GitHub issueThis change in 1.8.2: https://github.com/negomi/react-burger-menu/compare/v1.8.1...v1.8.2#diff-b9cfc7f2cdf78a7f4b91a753d10865a2
… will cause this.toggleMenu()
to be called whether or not isOpen
has changed. Within toggleMenu, onStateChange()
is always called: https://github.com/negomi/react-burger-menu/blob/9737db22668b7c876bd7f622aa158d1acbe6dd12/src/menuFactory.js#L34 .
In our application, we had assumed that this callback would only be triggered when the state changed, and unfortunately this ended up causing an infinite loop 😕
I could possible put together a PR with some improvements around this, although I’m confused by which branch I should be branching from … your remote master branch still states the version as 1.8.1.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
React Hooks - useEffect fires even though the state did not ...
The problem was that I was rendering the component with map() and there were cases where the key changed, and if the key...
Read more >Common Mistake with Synchronizing State in React -- newline
If some state is updating half way through a render, it may cause unexpected and difficult to debug changes to some other area/state....
Read more >React state not updating immediately? - Daggala
It might seems like the state update isn't updating or lagging behind. function onClick(){ //let's say last state was 1 setSomeState(2) ...
Read more >Changelog - Sinon.JS
Sinon 1.7 has split calls out to a separate file. This caused some problems, so 1.7.2 ships with spyCall as part of spy.js...
Read more >Changelog - Cypress Documentation
In Cypress v12, the testIsolation configuration values have changed from on or off ... Fixes an issue where session state was not being...
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 Free
Top 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
So I just found a couple of hours to look through the history at all the ways it’s been broken, and wrote some more comprehensive tests covering each case.
The logic change to make them all pass was pretty simple (checking for the isOpen prop being defined, and then checking for either a prop or state difference).
I haven’t merged it yet, but the diff is here if you feel like taking a look: https://github.com/negomi/react-burger-menu/compare/fix/isOpen-logic?expand=1
Thanks for your help!
Just pushed v1.8.3, which includes your suggested change, and a (now passing) test which fails with the logic I had before.
So that’s all the cases I know of covered and documented in tests for now!
Thanks again for your help with this 😃