Closed KrisLeeCoder closed 7 years ago
Components don't care about receiving actions. They dispatch them. It goes:
component -> action -> store -> back to component again
So the relevant question is the "So, HOW can I use store in react components without dealing with the whole triggered data?"
There are multiple ways of dealing with that.
There's storeKeys
for normal declarative style usage to filter out all but just the store properties you want.
And for more imperative/manual usage, you use mapStoreToState
to filter as well as format what parts of a store's state go into your component.
Component :
loginFom
. Store:UserStore
, bothlogin
andregister
actions are listened in it. Actions:login
, with childrencompleted
andfailed
;register
, with childrencompleted
andfailed
. Thelogin
andregister
action will send a ajax request, and callcompleted
if request succeed with user's data, or callfailed
with the error message. In loginForm component, I just need thelogin.success
action's returned data.So, HOW can I use store in react components without dealing with the whole triggered data? Or, HOW can I just receive one method's triggered data from store in components?