'action.payload in redux-tookit issue
i'm developing login authentication using BarCodeScanner from expo, so i'm trying to take the data from the QR code and send it to redux to change the state to authenticated or not, here is my state,
const initialState ={
usersList:["u125585212" , "u25487665542" , "u87sujdjk8554"],
authenticated : false ,
scannedNumber: false,
};
and the reducers,
reducers:{
authenticatedOperation :(state,action)=>{
if(state.usersList.indexOf(action.payload) !== -1){
state.authenticated = true ;
}else if(state.usersList.indexOf(action.payload) === -1){
state.authenticated = false ;
}
}
it always show me the result is -1 even if it's in my state i tried to dispatch any number from the array and it's worked but when i use action.payload is appear if i make console.log(action.payload) but if use for example
state.usersList.indexOf(action.payload) // the return -1 always
state.usersList.includes(action.payload) // the return false always
any help please ......
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
