TS is used in typeofKeyword can automatically get the data type

When writing React projects, there are times when you might have a default value for state, such as:

const initialState = {  
  loadTest: { 
    id: ' '.editor: ' ',},jsonList: [].isSetupCheck: false,
}
type IState = typeof initialState

class Comp extends Component<any.IState> {
   constructor(props) {
        super(props);
        this.state = {
            ...initialState
        };
    }
}Copy the code

This eliminates the need to separate the initial value of state from the type of state.