79543210

Date: 2025-03-29 12:06:54
Score: 1
Natty:
Report link

When you pass value directly from Parent to Child, TypeScript can't determine which variant of the union type will be received at compile time.

You can fix this by narrowing type inside Parent component.

const Parent = ({ value }: ChildProps) => {
    if (Array.isArray(value)) {
        return <Child value={value} />;
    } else {
        return <Child value={value} />;
    }
};
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (1):
Posted by: aashish-cd