If the attribute value of state in React is this.props.xx, it will be undefined.

for example, write code like this in a class component, state= {currentPic:this.props.pic}; pic is data passed in through connect (mapStateToProps), why is the value of each property of props in the constructor undefined? The function below the constructor uses this.props.xx but can access the value

Jun.01,2022

you passed the redux, you write the values in the reducer as fixed to see if you can get it, just check up a little bit


No props? Normally, you can get it

constructor(props) {
        super(props);
        this.state = {
            popover: false,
            Data:2,
            displayQrCode: false,
            imgBase64: '',
        };
    }
The value of props cannot be taken in

state because constructor is the first part of the component to execute. If the value of the property of state is this.props.xx, then it will be undefined (https://codeshelper.com/q/10...)

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be073a-314e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be073a-314e3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?