ts和react的默认属性的四种解决方案 Non-null assertion operator(非空断言语句) Component type casting(组件类型重置) High order function for defining defaultProps(高阶组件) Props getter function(Getter函数) 1. 非空断言语句 1.const color = this.props.color!; 2.this.props.onBlur ? this.props.
记录学习React时自己是如何挖坑把自己埋了的过程:children以及其它props被修改时相关组件无法重新渲染(做了两天) 父组件代码: class UserHome extends Component<Props, State> implements IUserHome { public name: string | undefined; public readonly state: State = initialState; public handlerClick() { store.