Closed it-efrem closed 4 years ago
You are calling a component as a function. Instead of store.map(Item)
do store.map(item => <Item .... />)
(note that this is further unrelated to MobX)
Isn't using a store.map(item => <Item .... />)
a bad approach?
No, why would it be? That is the only normal way of doing that in React I know :). It maps from values to component invocations. What you where doing was mapping from value to render logic, which would effectively create one gigantic React component that does everything. See for example https://kentcdodds.com/blog/dont-call-a-react-function-component
store.map(item => <Item {...item}/>)
It works!
Thanks for the quick reply and for the link to the article 💪
@mweststrate
I am guided by this, because an arrow function is also created here
store.map(item => <Item {...item}/>)
That is about passing arrow functions to other components, not the use of arrow functions inside the implementation (which useEffect etc do as well)
On Wed, Feb 5, 2020 at 12:54 PM Eugene Bukowski notifications@github.com wrote:
@mweststrate https://github.com/mweststrate
I am guided by this, because an arrow function is also created here store.map(item => <Item {...item}/>)
Docs: https://reactjs.org/docs/faq-functions.html [image: image] https://user-images.githubusercontent.com/20017668/73843418-abba5680-482f-11ea-8337-56f1432e4720.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx/issues/2272?email_source=notifications&email_token=AAN4NBHADCESJRKLVDQNIXDRBKZJBA5CNFSM4KQKHTVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK3KBFA#issuecomment-582394004, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBBTU7IUE56DUPJ5PL3RBKZJBANCNFSM4KQKHTVA .
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
[x] Provide error messages including stacktrace Click: After click and "white screen":
[x] Provide a minimal sample reproduction. **
Repository -> https://github.com/Evgeny-Bukovski/MobX-React-ToDo-Example-forms-fetch-async Commit with errors-> https://github.com/Evgeny-Bukovski/MobX-React-ToDo-Example-forms-fetch-async/commit/70260f861cdceb100e35eb3308f7f6ddb12f5e59
I expect a list item to be added without errors.