diff --git a/examples/09_reactmemo/src/TodoItem.tsx b/examples/09_reactmemo/src/TodoItem.tsx index 6e353cbe..afafca63 100644 --- a/examples/09_reactmemo/src/TodoItem.tsx +++ b/examples/09_reactmemo/src/TodoItem.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import { memo } from 'react-tracked'; import { useDispatch, TodoType } from './store'; @@ -9,8 +8,7 @@ type Props = { let numRendered = 0; -// Use custom memo instead of React.memo -const TodoItem = memo(({ todo }: Props) => { +const TodoItem = React.memo(({ todo }: Props) => { const dispatch = useDispatch(); return (
  • diff --git a/examples/15_reactmemoref/src/TodoItem.tsx b/examples/15_reactmemoref/src/TodoItem.tsx index 5a8baea6..68b92a4a 100644 --- a/examples/15_reactmemoref/src/TodoItem.tsx +++ b/examples/15_reactmemoref/src/TodoItem.tsx @@ -1,16 +1,16 @@ import React, { forwardRef } from 'react'; -import { memo } from 'react-tracked'; import { useDispatch, TodoType } from './store'; type Props = { + // FIXME why this complaints? + // eslint-disable-next-line react/no-unused-prop-types todo: TodoType; }; let numRendered = 0; -// Use custom memo instead of React.memo -const TodoItem = memo( +const TodoItem = React.memo( forwardRef(({ todo }, ref) => { const dispatch = useDispatch(); return ( diff --git a/src/index.ts b/src/index.ts index 4993bf39..97ae345e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,3 @@ export { createContainer } from './createContainer'; export { createTrackedSelector } from './createTrackedSelector'; -export { memo } from './memo'; export { getUntracked as getUntrackedObject } from 'proxy-compare'; diff --git a/src/memo.ts b/src/memo.ts deleted file mode 100644 index 14068eab..00000000 --- a/src/memo.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { createElement, memo as reactMemo, forwardRef } from 'react'; -import { trackMemo } from 'proxy-compare'; - -import type { - PropsWithChildren, - NamedExoticComponent, - ComponentType, - ComponentProps, - MemoExoticComponent, -} from 'react'; - -export function memo

    >( - Component: ComponentType

    , - propsAreEqual?: ( - prevProps: Readonly>, - nextProps: Readonly>, - ) => boolean, -): NamedExoticComponent

    ; - -export function memo>( - Component: T, - propsAreEqual?: ( - prevProps: Readonly>, - nextProps: Readonly>, - ) => boolean, -): MemoExoticComponent; - -export function memo(Component: any, propsAreEqual?: any) { - const WrappedComponent = forwardRef((props: any, ref: any) => { - Object.values(props).forEach(trackMemo); - return createElement(Component, { ...props, ref }); - }); - return reactMemo(WrappedComponent, propsAreEqual); -}