-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Editor: onTextChange handler does not reflect updated props #6067
Comments
IS that PrimeReact version 3.3.1 correct? The latest version is 10.5.1 have you checked this bug is not already fixed? |
@melloware the version has been corrected from 3.3.1 to 10.5.1 in this issue, my bad; yes, this is happening on the latest version. |
Thanks let me take a look! |
Weird I don't see anything obvious in the code that would cause this do you? The Editor component really doesn't have too much too it it just passes through to QuillJS? |
This should be a problem with react Hook to define an event handler with an always-stable function identity const fn = useEvent(()=>{
props.onTextChange()
})
useUpdateEffect(() => {
quill.current?.on('text-change', fn);
return () => {
quill.current?.off('text-change', fn);
};
});
|
@kl-nevermore are you going to provide a PR? If so I can assign this one to you? |
Fix #6067: Editor: onTextChange handler does not reflect updated props
Describe the bug
The onTextChange handler of the PrimeReact Editor component appears to be caching the initial value of props passed to its containing component, leading to inconsistencies in behavior when those props change.
Reproducer
https://stackblitz.com/edit/ylsaqj?file=src%2FApp.jsx
PrimeReact version
10.5.1
React version
18.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
<Editor />
.from the stackblitz example:
Expected behavior
You should be able to access the current prop values. Instead, props return their initial value.
The text was updated successfully, but these errors were encountered: