The reducer goes like this:
import {
CREATE_COUNTRY,
} from "../actions/actionConsts"
export const storeInitialState = {
countries: [],
otherThings: 0
}
export default function countriesReducer(prevState = storeInitialState, action) {
switch (action.type) {
case CREATE_COUNTRY:
return {
...prevState,
countries: [
...prevState.countries,
action.country
]
}
default:
return prevState
}
}
The action Creator is
export function createCountryActn(country) {
return {
type: CREATE_COUNTRY,
country
}
}
And the component where I trigger the action
… … … … …
createTheCountry = (e) => {
e.preventDefault()
this.props.createCountry(this.state.name)
this.setState({
name: '',
})
}
… …… … … …
What would be causing the store's state to be restarting everytime a add a new item?
Rafael