Search code examples
reactjsreduxreact-reduxstore

Where to initialize store when using connect in react-redux project


I am new to react and redux so am confused where to initialize store with dummy data? am using provider in the root component . the only two ways to access store i found are either using this:-

Provider.childContextTypes = {
   store: React.PropTypes.object
}

or by using connect ,

const mapStateToProps = state => ({
 state:state.contacts
});

const mapDispatchToProps = dispatch => ({
 setDummyData: () => dispatch(setDummyData())
});

export default connect(
 mapStateToProps,
 mapDispatchToProps
)(ComponentName)

but contacts isn't initialized .. How to approach?

any any links where i can find examples with connect and dummy data will be very helpful


Solution

  • do it either in createStore for whole store or in reducer(s) for each slice.

    https://redux.js.org/api/createstore