'Redux state isn't updating

Hello I have a problem with redux. It seems like state doesn't change. I'm using redux toolkit. The problem is in Main.js. When I call useEffect it sends request to database and should dispatch action. And this is working. I can see that reducer executes but that doesn't change the state value. I don't know why.

configSlice.js

const configSlice = createSlice({
name: "config",
initialState: null,
reducers: {
    saveConfig(state, action) {
        state = action.payload;
        console.log(state);
    },
    resetConfig(state) {
        state = null;
    },
},
});

export const configSliceActions = configSlice.actions;
export default configSlice;

Main.js

const Main = () => {
    const dispatch = useDispatch();
    const user = useSelector((state) => state.auth.user);
    const config = useSelector((state) => state.config);
    useEffect(() => {
        if (user) {
            get(ref(database, `${user.uid}/config`)).then((snapshot) => {
                if (snapshot.exists()) {
                    dispatch(configSliceActions.saveConfig(snapshot.val()));
                }
            });
        }
    }, []);
    if (!user) {
        return <Redirect to="/login" />;
    }
    if (!config) {
        return <ConfigPanel />;
    }
    return <div></div>;
};
export default Main;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source