Closed alexpchin closed 3 years ago
@alexpchin thanks for the PR, but not sure about the need of this. The definition of children is:
children: React.ReactElement[]
Here.
The children are always an array because I didn't see a use-case where we don't have children, or we have only one child. If children are not provided, there is no screen to be rendered. And if we have only one child, there is no need for tabs. Perhaps I'm missing something?
What do you think about throwing an error in case we have only one or zero children?
So whilst unlikely, you might have a scenario where you only have one tab and even more unlikely, undefined.
For example, if you used tabs for a profile page, but a certain user type only had one tab, this would not be an array. It would be more work to create two pages that dealt differently with the header and tabs.
Regarding the undefined, this is really, really unlikely. However, when developing perhaps we throw an error that is more helpful rather than just a crash?
Yes, I see your point, I agree. I did some changes on #74, let me know your thought.
Closing in favor of #74
feat: ensuring that children is not
undefined