React: Unable to get updated state(value) in grapesjs event callback function #3831
Unanswered
riteshagarwalsw
asked this question in
Q&A
Replies: 1 comment 1 reply
-
This is how React hooks work, you should learn how to handle them properly. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am facing an issue while integrating grapesjs with react.
I have a state in react component as below(Function component)
const [fileName, setFileName] = React.useState<string>('Default');
// versions
React version: 16.8.6
GrapesJS version: 0.17.19
Once the file name is changed by the user, using setFileName, I would like grapesjs to have access to the updated fileName.
Below example does not work.
Above code always prints "Default" as the file name. Although fineName is changed by the user(And react code is able to see the changes). But grapesjs code is not able to access the latest changes in fileName(It always gets the default value).
Please help me with some direction. I am stuck with this.
Beta Was this translation helpful? Give feedback.
All reactions