-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live stops if Date value is changed. #154
Comments
I'm experiencing this as well. any suggestions? |
same problem here. |
I am also experiencing this issue and think it's also probably the cause of the problem on this Stack Overflow question: https://stackoverflow.com/questions/66322904/how-to-fix-react-timeago-not-updating-on-its-own |
I was stuck on this for awhile, what worked for me was to add the date prop to the useEffect dependencies and then change Infinity to a large number. |
EDIT Unfortunately I've just realised that the times started updating when I pressed save on the code on the development server (repeatable behaviour). The times didn't start updating because of the code change below. I'm curious as to why saving my code (which triggers an update of the page - but not a proper refresh) starts the timers going again. I'll try to do some further debugging. Original Comment Brilliant. I didn't need to add the date prop to useEffect - I don't actually have a useEffect clause where that would be relevant. However, updating the Original Code: Updated Code: The time now updates as expected. Thank you for your help @BrennanWilkins - you've saved me a headache! |
Unfortunately I had to download the src files and make the edits to the index.js file. The useEffect in index.js was what I was referring to. |
Fix for issue nmn#154. useEffect dependencies updated to include [date]. This prevents an issue where my nested <TimeAgo /> component doesn't update on its own.
Thanks @BrennanWilkins - that's sorted the issue now. I don't actually need to update the |
Since the pull request was merged a new version has been published to NPM. |
Hello, good afternoon,
The live functionality stops working when you update the date object and the component re-renders. Is there any way to prevent this?
Thank you very much!
The text was updated successfully, but these errors were encountered: