Managing App States
FastUI uses Redux state management
instead of React state management for a much more maintainable decoupling of React components.
When is React state management better
We recommend using React state management when the state is scoped in a single node in DOM tree, because in this case Redux as a global management would be an overkill and React state management would not suffer prop-drilling at all
The template has already been configured with 2 states
- a string variable named
myState1
- a boolean variable called
myState2
import { selectMyState1, setMyState1, setMyState2 } from "fast-ui-redux";
function MyComponent(): JSX.Element {
const myState1 = useAppSelector(selectMyState1);
const myState2 = useAppSelector(selectMyState2);
console.log(setMyState1);
const dispatch = useAppDispatch();
dispatch(setMyState2(false));
}
export default App;