Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions compat/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,14 @@ declare namespace preact {
}

export interface Component<P = {}, S = {}> {
componentWillMount?(): void;
componentDidMount?(): void;
componentWillUnmount?(): void;
getChildContext?(): object;
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
shouldComponentUpdate?(
nextProps: Readonly<P>,
nextState: Readonly<S>,
nextContext: any
): boolean;
componentWillUpdate?(
nextProps: Readonly<P>,
nextState: Readonly<S>,
nextContext: any
): void;
getSnapshotBeforeUpdate?(oldProps: Readonly<P>, oldState: Readonly<S>): any;
componentDidUpdate?(
previousProps: Readonly<P>,
Expand Down
6 changes: 4 additions & 2 deletions demo/people/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export class Profile extends Component<ProfileProps> {
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() {
Expand Down
17 changes: 0 additions & 17 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 0 additions & 2 deletions src/index-5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ export type AnyComponent<P = {}, S = {}> =
| ComponentConstructor<P, S>;

export interface Component<P = {}, S = {}> {
componentWillMount?(): void;
componentDidMount?(): void;
componentWillUnmount?(): void;
getChildContext?(): object;
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
shouldComponentUpdate?(
nextProps: Readonly<P>,
nextState: Readonly<S>,
Expand Down
2 changes: 0 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ export type AnyComponent<P = {}, S = {}> =
| ComponentConstructor<P, S>;

export interface Component<P = {}, S = {}> {
componentWillMount?(): void;
componentDidMount?(): void;
componentWillUnmount?(): void;
getChildContext?(): object;
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
shouldComponentUpdate?(
nextProps: Readonly<P>,
nextState: Readonly<S>,
Expand Down
17 changes: 0 additions & 17 deletions test/ts/preact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ class ComponentWithLifecycle extends Component<DummyProps, DummyState> {
return <div>Hi</div>;
}

componentWillMount() {
console.log('componentWillMount');
}

componentDidMount() {
console.log('componentDidMount');
}
Expand All @@ -214,11 +210,6 @@ class ComponentWithLifecycle extends Component<DummyProps, DummyState> {
console.log('componentWillUnmount');
}

componentWillReceiveProps(nextProps: DummyProps, nextCtx: any) {
const { initialInput } = nextProps;
console.log('componentWillReceiveProps', initialInput, nextCtx);
}

shouldComponentUpdate(
nextProps: DummyProps,
nextState: DummyState,
Expand All @@ -227,14 +218,6 @@ class ComponentWithLifecycle extends Component<DummyProps, DummyState> {
return false;
}

componentWillUpdate(
nextProps: DummyProps,
nextState: DummyState,
nextContext: any
) {
console.log('componentWillUpdate', nextProps, nextState, nextContext);
}

componentDidUpdate(
previousProps: DummyProps,
previousState: DummyState,
Expand Down
Loading