diff --git a/compat/src/index.d.ts b/compat/src/index.d.ts index 093c7d0970..fa73cbe7ff 100644 --- a/compat/src/index.d.ts +++ b/compat/src/index.d.ts @@ -28,21 +28,14 @@ declare namespace preact { } export interface Component

{ - componentWillMount?(): void; componentDidMount?(): void; componentWillUnmount?(): void; getChildContext?(): object; - componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; shouldComponentUpdate?( nextProps: Readonly

, nextState: Readonly, nextContext: any ): boolean; - componentWillUpdate?( - nextProps: Readonly

, - nextState: Readonly, - nextContext: any - ): void; getSnapshotBeforeUpdate?(oldProps: Readonly

, oldState: Readonly): any; componentDidUpdate?( previousProps: Readonly

, diff --git a/demo/people/profile.tsx b/demo/people/profile.tsx index fb18f568f5..5d5f900859 100644 --- a/demo/people/profile.tsx +++ b/demo/people/profile.tsx @@ -14,8 +14,10 @@ export class Profile extends Component { this.id = this.props.route; } - componentWillReceiveProps(props: ProfileProps) { - this.id = props.route; + componentDidUpdate(prevProps: ProfileProps) { + if (prevProps.route !== this.props.route) { + this.id = this.props.route; + } } render() { diff --git a/src/diff/index.js b/src/diff/index.js index d9a62cbae5..b9031ad40d 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -147,27 +147,10 @@ export function diff( // Invoke pre-render lifecycle methods if (isNew) { - if ( - isClassComponent && - newType.getDerivedStateFromProps == NULL && - c.componentWillMount != NULL - ) { - c.componentWillMount(); - } - if (isClassComponent && c.componentDidMount != NULL) { c._renderCallbacks.push(c.componentDidMount); } } else { - if ( - isClassComponent && - newType.getDerivedStateFromProps == NULL && - newProps !== oldProps && - c.componentWillReceiveProps != NULL - ) { - c.componentWillReceiveProps(newProps, componentContext); - } - if ( (!c._force && c.shouldComponentUpdate != NULL && diff --git a/src/index-5.d.ts b/src/index-5.d.ts index 1431b01f30..b9ab2035b0 100644 --- a/src/index-5.d.ts +++ b/src/index-5.d.ts @@ -111,11 +111,9 @@ export type AnyComponent

= | ComponentConstructor; export interface Component

{ - componentWillMount?(): void; componentDidMount?(): void; componentWillUnmount?(): void; getChildContext?(): object; - componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; shouldComponentUpdate?( nextProps: Readonly

, nextState: Readonly, diff --git a/src/index.d.ts b/src/index.d.ts index e6b8fd549e..d9d9eaf393 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -111,11 +111,9 @@ export type AnyComponent

= | ComponentConstructor; export interface Component

{ - componentWillMount?(): void; componentDidMount?(): void; componentWillUnmount?(): void; getChildContext?(): object; - componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; shouldComponentUpdate?( nextProps: Readonly

, nextState: Readonly, diff --git a/test/ts/preact.tsx b/test/ts/preact.tsx index c0fe2cfc08..43ce44427f 100644 --- a/test/ts/preact.tsx +++ b/test/ts/preact.tsx @@ -202,10 +202,6 @@ class ComponentWithLifecycle extends Component { return

Hi
; } - componentWillMount() { - console.log('componentWillMount'); - } - componentDidMount() { console.log('componentDidMount'); } @@ -214,11 +210,6 @@ class ComponentWithLifecycle extends Component { console.log('componentWillUnmount'); } - componentWillReceiveProps(nextProps: DummyProps, nextCtx: any) { - const { initialInput } = nextProps; - console.log('componentWillReceiveProps', initialInput, nextCtx); - } - shouldComponentUpdate( nextProps: DummyProps, nextState: DummyState, @@ -227,14 +218,6 @@ class ComponentWithLifecycle extends Component { return false; } - componentWillUpdate( - nextProps: DummyProps, - nextState: DummyState, - nextContext: any - ) { - console.log('componentWillUpdate', nextProps, nextState, nextContext); - } - componentDidUpdate( previousProps: DummyProps, previousState: DummyState,