0

Is it possible to configure an initial state of the redux store in react-native-debugger?

I'm imagining pointing it towards a JSON file on my disk or something like that.

This would allow be to have arbitrary places in user journeys as my starting point, that require a complex state of the redux store to already be present.

Jonas Kemper
  • 3,745
  • 3
  • 14
  • 21
  • do you actually want some redux store to be present when you start/restart your app ? if so then you can hydrate the store when the app launches – warl0ck Mar 27 '19 at 11:14
  • Yes, that's what I want! What does "hydrating the store" mean? – Jonas Kemper Mar 27 '19 at 11:19
  • its just fancy way of saying restoring the old saved store, I have posted the exmaple on how you can retrieve the store and save it – warl0ck Mar 27 '19 at 12:25

1 Answers1

-1

Before creating the store just read the json file that you need with your inital state and call it that way:

// store.js
import { data } from "yourFile.json";
...

const mydata = JSON.parse(data);
const store = createStore(
  app,
  mydata
);
Carlos Ruana
  • 2,138
  • 1
  • 15
  • 14