I'm trying to have a function run only when the contentState itself has changed, not just the editorState.
My idea right now would be to store the old contentState as a string and compare it to the new contentState as a string, but this seems awfully wasteful to be converting states to strings and comparing them. Is there a better way?
you can simply compare the value of your old state
and the value of your new state
you don't have to convert
it to string
.
EDIT: and here is a concept about react state
that you don't have worry about a large state object
as best practices recommend to do that way
Common misconception:
state
is held in alarge object
. It’s just object referencing a few other objects. Nothing large about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With