Skip to content
Advertisement

Initialise helper class in a react functional component

The class methods which are passed as args from the functional component, are kept ‘in memory’ and doest not reflect the updated state. I can reinitialise on state changes but wish to avoid it.

JavaScript

Advertisement

Answer

You’ll need an additional ref to be able to use the latest values in an async callback.

Either

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement