I created a react component which takes 2 props: func1, func2.
const Component = ({ func1, func2 }) => {
return (
<Button
onClick={() => {
func1();
func2();
}}
>
Click
</Button>
);
};
The above component is reusable. I have a situation where I pass both functions (func1, func2) as props in this component:
<Component func1={functionA} func2={functionC}/>
I also have situations where I don't pass both props:
<Component func1={functionA}/>
In the last case, how to set the func2 as alternative prop?
funct1andfunct2on conditional basis?funct1 && funct1()<Component/>like in the last case i don't want to get the error, that i forgot to passfunc2. I need to change something in the Component, and to be prepared that both props could be use not as required.func2 = () => return false