Passing props in parent component
React I have two types of components:
- List
- option (component CheckboxOption or RadioOption could be used in props.children)
Now I want to use it in the app, how can I do it without repeating props? (Example is simplified, and in real scenario CheckboxOption could be also replaced with RadioOption etc...
page.tsx
2 Replies
You can have optional props, you can have default values, or you can not pass a prop and it will be undefined.
If I set props to optional, in the option components I will have to handle many really unnecessary checks to control flow of code.
Idea with default values (kinda dummy values) can be worth trying, I will test it and report back later.