Answer the question
In order to leave comments, you need to log in
Why does map swear at redux in react?
render(){
// так не работает
console.log(this.props.testT);
const numbers = this.props.testT;
const listItems = numbers.map((number, index) =>
<li key={index}>{number}</li>
);
//так работает
const vals= ["Param","New"];
const listItems = vals.map((vals, index) =>
<li key={index}>{number}</li>
);
console.log(vals);
return(
<div>
<ul>
{listItems}
</ul>
</div>
)}
...
export default connect(
state => ({
testT: state
}),
dispatch => ({})
)(App);
const initialState = [
"Param",
"New"
];
function test(state = initialState, action) {
// console.log(action)
if(action.type === 'ADD_TEST'){
return [
...state,
action.name
]
}
return state;
}
const store = createStore(
test,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
Answer the question
In order to leave comments, you need to log in
I found the problem is that I have __REDUX_DEVTOOLS_EXTENSION__ connected,
it saved the old state from before launch and because of this it conflicts.
Apparently in REDUX_DEVTOOLS you can somehow clear the cache.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question