41. If you need to optimize react performance (generally not needed) if both state and props of a component are simple types, you can inherit PureComponent instead of Component import { Component, PureComponent } from 'react'; // bad class Message extends Component { render() { return <span>{this.state.message}</span>; } } // good class Message extends PureComponent { render() { return <span>{this.state.message}</span>; } } override the shouldComponentUpdate method to determine whether re-rendering is needed in shouldComponentUpdate based on whether the state,props has changed. If the component inherits PureComponent, there is no need to override the shouldComponentUpdate method import { isReactPropsEqual, isReactStateEqual } from '@fe/common/lib/equal'; shouldComponentUpdate(nextProps:IProps, nextState:IState) { if (isReactStateEqual(nextState,this.state) && isReactPropsEqual(nextProps,this.props)) { return false; } return true; } 42. Event event object type many friends have used ts for a long time, but they don't know the common Event event object types: ClipboardEvent Clipboard event object DragEvent drag event object ChangeEvent Change event object KeyboardEvent keyboard event object MouseEvent mouse event object TouchEvent Touch event object WheelEvent wheel event object AnimationEvent animated event object TransitionEvent transition event object import { MouseEvent } from 'react'; interface IProps { onClick(event: MouseEvent<HTMLDivElement>): void; } 43. Replace state status with private attributes for some status attributes that do not need to control ui, we can bind them directly to this, that is, private attributes. There is no need to apply them to this.state, otherwise the rendering mechanism will be triggered and performance will be wasted. For example, when we request paging data, we will have a variable. // bad state: IState = { pageNo:1, pageSize:10 };…