What is the best practice to save access token in react-native app with redux?
In Redux, I used to save the whole credential, including some user information to the state:
//Actions
export const successfulLogin = (firebaseAuth) => ({
type: 'LOGIN_SUCCESSFUL',
firebaseAuth
});
//Reducer
const authentication = (state = {}, action) => {
switch (action.type) {
case 'LOGIN_SUCCESSFUL':
return {
...state,
firebaseAuth: action.firebaseAuth
};
default:
return state;
}
}
export default authentication
After that, I found a new module redux-persist, which helps me to save the state to device storage, localStorage. However, everything in the store will be saved. Is it a good practice to save access token with redux-persist?
If not, what should I use?