Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript is not happy with react-tracked. What am I missing here? #59

Closed
clechner77 opened this issue Aug 1, 2020 · 7 comments
Closed

Comments

@clechner77
Copy link

Ideas how to work around this with Provider?

(alias) const Provider: React.ComponentType
import Provider
JSX element type 'ReactElement<any, any> | Component<unknown, any, any>' is not a constructor function for JSX elements.
Type 'Component<unknown, any, any>' is not assignable to type 'Element | ElementClass'.
Type 'Component<unknown, any, any>' is not assignable to type 'ElementClass'.
The types returned by 'render()' are incompatible between these types.
Type 'ReactNode' is not assignable to type 'false | Element'.
Type 'string' is not assignable to type 'false | Element'.ts

@dai-shi
Copy link
Owner

dai-shi commented Aug 1, 2020

Hi, I'm not sure if I understand how this is happening. Would it possible to create a reproduction, possibly with codesandbox.

One thing in mind isReact.ComponentType is not like what I expected. Would you be able to change it to React.FC and see if it works?

@Aslemammad
Copy link

I'm so happy with this Project. If you want, I can move it to typescript and have better types. because most of my projects are ts. Is it OK to take the PR and change all the files to real ts?

@dai-shi
Copy link
Owner

dai-shi commented Aug 8, 2020

@Aslemammad Hey, thanks for volunteering!

Actually, I already developed v2 in all TS. #43
We are waiting for React to finalize their new hook.

In that sense, we shouldn't spend too much effort for v1. I think we can just modify the current index.d.ts in v1 to fix the issue reported here. Do you know what the issue is?

I wonder if @clechner77 is still around.

@Aslemammad
Copy link

OOOh thanks, Maybe I'll take the other issues.

@dai-shi
Copy link
Owner

dai-shi commented Sep 8, 2020

eb0c9d7 changed it to FC. Hoping it helps...

@clechner77
Copy link
Author

Sorry, I am alive!!!! Long story....

Simple change to FC may be all that's needed.

@dai-shi
Copy link
Owner

dai-shi commented Sep 8, 2020

Published: https://www.npmjs.com/package/react-tracked/v/1.4.2

I'm not quite sure if this resolves the issue described here, but let me close this. Feel free to reopen this if the problem persists.

@dai-shi dai-shi closed this as completed Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants