'React: Property 'Item' does not exist on type
Trying to resolve this tsconfig issue but unsure how to proceed:
Property 'Item' does not exist on type '{ ({ children, spacing }: { children: any; spacing: any; }): Element; propTypes: { children: Requireable<ReactNodeLike>; spacing: Requireable<string>; };
Basically I have the element called Stack that looks like this:
const Stack = ({ children, spacing }) => {
const items = findChildrenByRole(children, 'Stack.Item');
return children ? <div>{items}</div> : null;
};
Stack.propTypes = {
children: T.node,
spacing: T.oneOf(['none', 's', 'm', 'l']),
};
Stack.defaultTypes = {
spacing: 'none',
};
export default Stack;
I think have an ìndex.js file like this:
import Stack from './Stack';
import Item from './SubComponents/Item';
Stack.Item = Item;
export { Stack };
I use it like this:
<Stack spacing="s">
<Stack.Item>
Item
</Stack.Item>
</stack>
How do i make it understand that Item exists in my vscode?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
