Last active
September 7, 2020 16:16
-
-
Save dance2die/59a29c7b9a6be44d59a3f2893dac5c1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* No longer works | |
* Refer to https://sung.codes/blog/2018/11/08/emulate-forceupdate-with-react-hooks/ | |
**/ | |
import React, { useState } from 'react'; | |
const useForceUpdate = () => useState()[1]; | |
const App = () => { | |
const forceUpdate = useForceUpdate(); | |
console.log('rendering'); | |
return <button onClick={forceUpdate}>Click To Render</button>; | |
}; | |
export default App; |
Hi @cristinaITdeveloper.
It no longer works and I shoulda linked to the blog post that addresses it.
https://sung.codes/blog/2018/11/08/emulate-forceupdate-with-react-hooks/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It doesn't work for me. I get this error:
Possible Unhandled Promise Rejection (id: 7): Error: Invalid hook call. Hooks can only be called inside of the body of a function component.