When I click a button, I want to toggle the state between "true" and "false" and save it using AsyncStorage in a React Native app with Redux. Can someone review my code and help me correct it if needed?
import { AsyncStorage } from "react-native";
import {
START_TOOLTIP_BUDGET,
STOP_TOOLTIP_BUDGET
} from "../actions/ActionTypes";
const INIT_STATE = true;
export default (state = INIT_STATE, action) => {
switch (action.type) {
case START_TOOLTIP_BUDGET:
AsyncStorage.setItem("INIT_STATE", JSON.stringify(true));
return INIT_STATE;
case STOP_TOOLTIP_BUDGET:
AsyncStorage.setItem("INIT_STATE", JSON.stringify(false));
return INIT_STATE;
default:
return state;
}
};