nirus/IonicBaseplate

Can I find an example of how to use Context among different pages?

wakqasahmed opened this issue · 2 comments

Hi,

It's not an issue, I am just trying to use context to share between different pages but I haven't ever used React Boilerplate (which this repo is inspired from) and not so proficient in React-Redux (you can infer that Saga and ImmerJS are alien to me).

I want to have initial context at the Homepage, set different value from another page and use the value in third page. i.e.

  1. On application load - set the context as default
  2. On a page upon button click - set the context to a random value
  3. On a third page - Show the value saved in context

Could you help in this regard?

@nirus any help is much appreciated.

nirus commented

@wakqasahmed its basically same as what is available in the react documentation. Redux gives one single source of truth that your whole app can use to maintain the state of the app. You can refer the React.context example to make local contexts based on your needs. This boilerplate no where stops you doing that.

More walkthrough link - https://kentcdodds.com/blog/how-to-use-react-context-effectively