I have a Stateless Functional Component with an optional function parameter as property (onClick), I tried to define an empty function as default property to be able to do safely in my component :
<span onClick={props.onClick} />
But I have the following error : 'Expression expected.'
interface IProps {
size?: sizeType;
onClick?: (e:any) => void;
}
const Foo: React.SFC = (props: IProps) => {
// ...
};
const defaultProps: IProps = {
size: 'default',
onClick: () => void <-- Expression expected.
};
Foo = defaultProps;
How can I should do this?
IPropsto your question?