react native - Am i implementing redux correctly in my ReactNative app? -


i implementing mobile application using reactnative redux, app implementing looks that:

login (screen)  |--> search object (screen)    |--> show object , edit (screen)       |--> take 2 photos (each photo screen)          |--> last screen make new object , save 

the above flow shows how each screen work , pass next screen.

my application state next:

{   auth: {     logged: false,     token: ''   },   somethingofsidebar... } 

but feel doing things in wrong way, because of screens have own state, example searchsomethingscreen fetch data server, check if valid , enable pass next screen. feel not doing things in redux way, suppose make actions change entire state application, feel not need more state have. me global things auth data , sidebar (because present across entire application).

should make actions every screen change? should put more information in global state application?

a 1 more thing, have appcontainer component used in connect have access store, passing parts of state , actions children properties , feel wrong well.

i feel redux reddit tutorial may useful you. me.

but feel doing things in wrong way, because of screens have own state, example searchsomethingscreen fetch data server, check if valid , enable pass next screen.

used in redux way, api requests , successful completion should each map 1 action. change application state appropriately (in reducing function) on each action , views/screens bound store re-render. if you're making api request:

  • create search container, mapping state searchresults props , binding search component. (for example, see this container.)
  • fire action request_search search term on user input.
  • ajax request fired.
  • ajax request completes. fire action receive_search search results.
  • searchreducer stores search results.
  • bound search component re-renders search results.

should make actions every screen change? should put more information in global state application?

as general rule, yes. i've used component state (without dispatching action) store state local component (e.g. updating text field).

a 1 more thing, have appcontainer component used in connect have access store, passing parts of state , actions children properties , feel wrong well.

in general, higher level components should containers, inject state stateless components via props. can have more 1 containers , work components, can nest container in container. encourage have @ docs, useful me. :)


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -