dai-shi / react-tracked

State usage tracking with Proxies. Optimize re-renders for useState/useReducer, React Redux, Zustand and others.

Home Page:https://react-tracked.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prop types are lost when using memo

G07cha opened this issue · comments

I've noticed that with move to typescript while losing memo from react-tracked props types defined as generics to FC or VFC are not being passed through unless they are specified in callback arguments itself. I've tried fixing it myself but wasn't able to unfortunately, hence made this issue.

// Works
const MyComponent = memo(({ foo }: { foo: string }) => {})

// Doesn't, typeof foo is 'any'
const MyComponent: FC<{ foo: string }> = memo(({ foo }) => {})

Here is another example in sandbox:

Schermafbeelding 2021-01-14 om 13 14 58

You can try it out here: https://codesandbox.io/s/friendly-rhodes-n8rm8?file=/src/components/FilterLink.tsx

Accidental duplicate