I have a react context which is being used as a provider across multiple components.
I want to modify that state and update the UI from a normal method totally outside of React components. ie NOT a functional component or class, just a normal piece of JS code.
From what I can see the provider/context can only be accessed from within a render method or React.FC
I can pass a function in but it seems only from some type of React component that is sandwiched between <Context.Provider>
and useContext
only lights up once the relevant item has been passed into a render loop.
Is there a way I can create some type of store
that I can just call a setState()
method on its data, but where such updates would be reactive in the UI?
[edit] The reason I want this is cos I have an external API call that gives me a long running callback. I don't see a need to wrap that API up in all kinds of react stuff as I want that module to be portable (eg to server side) and just interact with app state to update the UI display.