Redux,state can be modified without action

If the store status of

1.redux is a reference type, you can directly modify the store.getState (). Xxx.xxx=? Modify it directly;

    let state1 = {person: {name:"ss"}}
    
    function reduce(state = state1, action) {
        return {...state}
    }
    const store = Redux.createStore(reduce)
    
    console.log(store.getState()) // lisi
    let tempState = store.getState()
    tempState.person.name="lisi"
    console.log(store.getState()) // lisi

question: official documents make it clear that status can only be modified through action. Is it because state management uses incorrect scenarios? Ask for help.

Jun.26,2021

what is stored in store is ordinary Object,. You can modify the attribute value directly in this way.

the official document says that "state can only be modified through action" is more of a rule / constraint that aims to make the flow of data clear and predictable, rather than saying that errors will be reported in other ways, such as directly modifying object properties.

of course you can't trigger props updates in this way

Menu