Skip to content

Commit b47404b

Browse files
committed
docs: patch doc info
1 parent 1081a9d commit b47404b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Immutable.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import * as React from 'react';
33

44
const RenderContext = React.createContext<number>(0);
55

6+
/**
7+
* Wrapped Component will be marked as Immutable.
8+
* When Component parent trigger render,
9+
* it will notice children component (use with `responseImmutable`) node that parent has updated.
10+
*/
611
export function makeImmutable<T extends React.ComponentType<any>>(Component: T): T {
712
const refAble = supportRef(Component);
813

@@ -25,6 +30,10 @@ export function makeImmutable<T extends React.ComponentType<any>>(Component: T):
2530
return refAble ? React.forwardRef(ImmutableComponent) : (ImmutableComponent as any);
2631
}
2732

33+
/**
34+
* Wrapped Component with `React.memo`.
35+
* But will rerender when parent with `makeImmutable` rerender.
36+
*/
2837
export function responseImmutable<T extends React.ComponentType<any>>(Component: T): T {
2938
const refAble = supportRef(Component);
3039

0 commit comments

Comments
 (0)