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 Props Type Definition for StateInspector is incompatible with children prop #83

Open
rogi29 opened this issue Aug 20, 2023 · 2 comments

Comments

@rogi29
Copy link

rogi29 commented Aug 20, 2023

Description

Integrating the StateInspector into a strict TypeScript react project will fail at build time.
Inserting React Nodes as a children prop into the StateInspector component will result with a TypeError.
In my specific case I was trying to insert my App component as a children prop and got an error from my IDE.

Error message

image

Code Example

import { StateInspector } from "reinspect";
import { App } from "./app";

export const AppWrapper = () => {
  return (
    <StateInspector>
      <App />
    </StateInspector>
  );
}

Suggestion

After reviewing the source code, indeed the children prop was not defined and there was no use of the PropsWithChildren type.
This is absolutely necessary in my opinion, and I am willing to provide a solution and post a pull request to fix this issue.

@rogi29
Copy link
Author

rogi29 commented Aug 20, 2023

I have to emphasis that this is an issue for React >18, as noted in the stackoverflow below, the React.FC type does not include the children: ReactNode anymore.
https://stackoverflow.com/questions/71788254/react-18-typescript-children-fc/71800185#71800185

rogi29 added a commit to rogi29/reinspect that referenced this issue Aug 20, 2023
As noted in the issue below, currently inserting React Nodes as a children prop into the StateInspector component will result with a TypeError.
troch#83

This is an issue for React >18 only, as noted in the stackoverflow below, the React.FC type does not include the children: ReactNode anymore.
https://stackoverflow.com/questions/71788254/react-18-typescript-children-fc/71800185#71800185
@rogi29
Copy link
Author

rogi29 commented Aug 20, 2023

I created a fork and opened a pull request with the relevant changes to support react >18 with typescript:
80a1531

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

1 participant