slow-yellowS
Refine4y ago
4 replies
slow-yellow

defaultProps ignored?

but
I've a custom component with default props like

---------

./Custom.jsx

export const Custom = ({ custom1, custom2, ...props }) => {
...
};

Cutom.defaultProps = {
custom1: 'C1',
custom2: 'C2'
};

export default Custom;

------------------

I'm using it like:

import { Custom } from "../Custom"

<Custom custom1="XXX" />

but I'm getting this error:

TS2739: Type '{ custom1:string; }' is missing the following properties from type '{ ... }': custom2

now... why is it not using the defaultProps definition?

is it possible to somehow disable it as I've a full library that is using .defaultProps in the component definitions?

Thanks
Was this page helpful?