PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
836 stars 162 forks source link

feat: small v3 fixes #69

Closed alexpchin closed 3 years ago

alexpchin commented 3 years ago

feat: ensuring that children is not undefined

PedroBern commented 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?

PedroBern commented 3 years ago

What do you think about throwing an error in case we have only one or zero children?

alexpchin commented 3 years ago

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?

PedroBern commented 3 years ago

Yes, I see your point, I agree. I did some changes on #74, let me know your thought.

PedroBern commented 3 years ago

Closing in favor of #74