Answer the question
In order to leave comments, you need to log in
Why is the state not filled after input?
I have created a page that has a textarea input field.
function Page1() {
function handleChange(e) {
store.dispatch({ type: 'CHANGE_VALUE', appText: e.target.value });
}
return (
<div>
<textarea
value={store.getState().appReducer.newAppText}
onChange={handleChange}>
</textarea>
<button>send</button>
<div id="output"></div>
</div>
);
}
let reducers = combineReducers({
appReducer
});
const store = createStore(reducers);
export default store;
store.subscribe(v => {
console.log(store.getState())
});
// store.dispatch({ type: 'CHANGE_VALUE', appText: 222 });
window.state = store.getState()
// store.dispatch({ type: 'CHANGE_VALUE', appText: 222 });
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question