Skip to content

Commit bfc84c1

Browse files
committed
refactor: use React.memo instead
1 parent 921a08f commit bfc84c1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Immutable.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export function makeImmutable<T extends React.ComponentType<any>>(Component: T):
2828
export function responseImmutable<T extends React.ComponentType<any>>(Component: T): T {
2929
const refAble = supportRef(Component);
3030

31-
const ImmutableComponent = function (props: any, ref: any) {
31+
const ImmutableComponent = React.memo(function (props: any, ref: any) {
3232
const refProps = refAble ? { ref } : {};
33-
const renderTimes = React.useContext(RenderContext);
33+
React.useContext(RenderContext);
3434

35-
return React.useMemo(() => <Component {...props} {...refProps} />, [renderTimes]);
36-
};
35+
return <Component {...props} {...refProps} />;
36+
});
3737

3838
if (process.env.NODE_ENV !== 'production') {
3939
ImmutableComponent.displayName = `ImmutableResponse(${

0 commit comments

Comments
 (0)