-
Hi All, I have a question. I worked on a project in react with mobx v.4 and at this moment I started loved mobx and using it everywhere. Now I am working on my project where I want include a mobx v.6 but I found one problem. In mobx v.4. was possible in the store had an array of components. For example :
userComponentArray looks like this:
In mobx v.4 wasn't any problem when I try to call and render somewhere in the project like Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. I cannot find a reason why the same construction cannot be work. Or maybe I caught mobx wrong and this idea of the array issn't supported. If am wrong, I would like to ask if is possible to make array of users names(it is simple html with DIVs) and share this array in all components in the project. I am using webpack and babel for building react app. Babel config:
webpack confing:
CodeSandbox example with error: https://codesandbox.io/s/damates-react-mobx6-mjexk?file=/src/App.js Thank you all for any comment about this problem because in my project I stuck in one place. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Please supply a runnable example with MobX 6. |
Beta Was this translation helpful? Give feedback.
-
That's not the fault of MobX, you are trying to render |
Beta Was this translation helpful? Give feedback.
That's not the fault of MobX, you are trying to render
toJS
result which is an object, and React doesn't know what to do with it. Either convert it to string withJSON.stringify
or.map
over it to render the component.