xxxxxxxxxx
import { createStore } from 'redux'
function todos(state = [], action) {
switch (action.type) {
case 'ADD_TODO':
return state.concat([action.text])
default:
return state
}
}
const store = createStore(todos, ['Use Redux'])
store.dispatch({
type: 'ADD_TODO',
text: 'Read the docs'
})
console.log(store.getState())
// [ 'Use Redux', 'Read the docs' ]
xxxxxxxxxx
//how to create a store in redux ?
//import your root reducer
import rootReducer from "./rootReducer"
//import createStore form redux
import {createStore} from "redux"
//creating store
const store =createStore(rootReducer)