Open Tuuben opened 2 years ago
Quick fix: Just add to CollapsibleProps
in index.d.ts
property children: ReactNode;
and it works well.
Hacky workaround:
<Collapsible
collapsed={isCollapsed}
// workaround: children prop not in TS definitions
{...{
children: props.children // <-- put children here
}}
/>
You can safely extend the type without modifying any files in node_modules:
import { CollapsibleProps as OriginalCollapsibleProps } from "react-native-collapsible";
declare module "react-native-collapsible" {
interface CollapsibleProps extends OriginalCollapsibleProps {
children?: React.ReactNode;
}
}
EDIT this can be simplified:
// this file must be a module - at least one import/export will force that
export {};
declare module "react-native-collapsible" {
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces
interface CollapsibleProps {
children?: React.ReactNode;
}
}
A fix for this issue has already been merged in Jun 2022. Apparently this lib only needs a minor/major release.
Who is the person that is able to do minor/major release?
@oblador any chance a minor release could be published to get the React 18 fix out?
Looks like v1.6.1 released that fix. @oblador we can close this issue out!
After updating to
"react-native": "0.70.3"
and"react": "18.1.0"
types break when passing children to a<Collapsible />
component. Same issue occurred with other libraries as well but got fixed when updated to latest versions. But this issue seems to not be fixed in version1.6.0
.Full TS error