A
A
Artem Lukyanov2019-09-19 12:34:59
React
Artem Lukyanov, 2019-09-19 12:34:59

Get mobx state outside React component?

There is a mobx store, how to access it outside the react component, but for example in another store or just a .js script?
There are several stores, I initialize everything in _app.js, to access them I use inject in the desired component.
I tried to export an object with all the stores from _app.js, but then when accessing any variable, the error "Rendered fewer hooks than expected" occurs

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Lukyanov, 2019-09-19
@ArtyomPLAY

Problem solved.
My mistake was to initialize the store directly in _app.js.
I did the initialization of the store in a separate file in export default, so now I just import the store from this file and access the state without problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question