sahlhoff / react-native-pulse

React Native Pulse Animation
MIT License
149 stars 49 forks source link

Issue: React setState can only update a mounted or mounting component #6

Closed levsthings closed 7 years ago

levsthings commented 7 years ago

@sahlhoff I really like the module but I'm having a problem with the React setState can only update a mounted or mounting component warning when changing views thus unmounting a component which uses this module.

Do you have any plans for clearing the callbacks?

sahlhoff commented 7 years ago

@levsthings no plans currently. Accepting PR's if you want to contribute. If not I'll look at it this over the weekend.

-Chad

yerushanuh commented 7 years ago

@sahlhoff I believe I have resolved this issue with my pull request last time: https://github.com/sahlhoff/react-native-pulse/pull/5

But the npm package has not been updated.

levsthings commented 7 years ago

Clearing the timers was a great addition but that doesn't fix this particular problem. (I'm using the component from the repo.)

I'll post a detailed issue report in a few hours.

levsthings commented 7 years ago

React Native Version : 0.42.0 React-Native-Pulse Version : Latest from the GitHub Repo

Problem: When user navigates away from a component that is rendering Pulse, you get the following warning. (Even though Pulse is dismounted.)

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the Pulse component.

StackTrace:

/project/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js:48
/project/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactUpdateQueue.js:234
/project/components/Pulse.js:106
/project/components/Pulse.js:60
/project/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:80
/project/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:80
/project/node_modules/react-native/Libraries/Core/Timers/JSTimersExecution.js:136
/project/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108
/project/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:46
/project/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:107

I'm trying to think of some solutions but couldn't come with anything other than suppressing the warnings with a hacky method. Any ideas @sahlhoff @yerushanuh ?

muresanandrei commented 7 years ago

So is there a fix for this?

glebcha commented 7 years ago

@muresanandrei @sahlhoff you can watch/merge my PR https://github.com/sahlhoff/react-native-pulse/pull/7

sahlhoff commented 7 years ago

Closing this after merging #7