Answer the question
In order to leave comments, you need to log in
Why can't the data that is stored in the store be redefined inside a function that is declared in a React component?
there is a reducer:
const initState = Immutable.fromJS({
isConfirmation: false
});
export default function auth(state = initState, action) {
switch (action.type) {
case actions.SET_AUTH_SUCCESS: {
return state.merge({
isConfirmation: true,
});
}
default:
return state;
}
}
setAuth: body => async (dispatch) => {
try {
const { data } = await fetch(body);
dispatch({
type: actions.SET_AUTH_SUCCESS,
payload: data,
});
} catch (error) {
dispatch({
type: actions.SET_AUTH_FAILURE,
});
}
}
const Auth = (props) => {
const { isConfirmation } = props;
const handleSubmit = async () => {
await setAuth()
console.log(isConfirmation)
}
return (
<button onClick={handleSubmit} />
)
}
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