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 React: incorrect children props #193

Open
ChromeQ opened this issue Apr 12, 2022 · 3 comments
Open

TypeScript React: incorrect children props #193

ChromeQ opened this issue Apr 12, 2022 · 3 comments

Comments

@ChromeQ
Copy link

ChromeQ commented Apr 12, 2022

#192 fixes TS errors since DefinitelyTyped updated react types to v18.

@Pabliomen
Copy link

@ChromeQ is there a way we can use your fork as a temporary solution?

I've tried adding it to my packages with yarn add ChromeQ/redux-dynamic-modules but it looks like it can't find it.

@mrluscus
Copy link

Based on this PR: #192

You can extend 'IDynamicModuleLoaderProps' interface in your *.d.ts (like in global.d.ts). Just add:

declare module 'redux-dynamic-modules-react' {
  export interface IDynamicModuleLoaderProps {
    /** Explicitly name children as a prop to work with @types/react@18 */
    children: React.ReactNode;
  }
}

@davoam
Copy link

davoam commented Feb 22, 2024

Thanks @mrluscus ! I just want to add that in our case without importing redux-dynamic-modules-react other error appeared. It was complaining that DynamicModuleLoader is not exported.

Our solution was:

  1. Create file redux-dynamic-modules-react.d.ts (optional, you may add lines below to global.d.ts)
  2. Add the following content
import * as reduxDynamicModulesReact from 'redux-dynamic-modules-react';

declare module 'redux-dynamic-modules-react' {
  export interface IDynamicModuleLoaderProps {
    children: React.ReactNode;
  }
}

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

4 participants