MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiv2dad/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
9
I love this when using react: this.setState({ toggle: !toggle });
34 u/snorkl-the-dolphine Mar 18 '19 This can cause issues of it runs twice in quick succession. The safe way to do this is:this.setState(({toggle}) => {toggle:!toggle}); 1 u/disclosure5 Mar 19 '19 I get why it's a problem, can I get a reference or ELI5 on why that solution is any safer? → More replies (1)
34
This can cause issues of it runs twice in quick succession. The safe way to do this is:
this.setState(({toggle}) => {toggle:!toggle});
1 u/disclosure5 Mar 19 '19 I get why it's a problem, can I get a reference or ELI5 on why that solution is any safer? → More replies (1)
1
I get why it's a problem, can I get a reference or ELI5 on why that solution is any safer?
→ More replies (1)
9
u/geoffgiller8 Mar 18 '19
I love this when using react: this.setState({ toggle: !toggle });