File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ import * as React from 'react';
33
44const 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+ */
611export 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+ */
2837export function responseImmutable < T extends React . ComponentType < any > > ( Component : T ) : T {
2938 const refAble = supportRef ( Component ) ;
3039
You can’t perform that action at this time.
0 commit comments