react-native-elements icon indicating copy to clipboard operation
react-native-elements copied to clipboard

Tab 'selected=true' causes React.Children.only error

Open danikenan opened this issue 10 years ago • 4 comments

The simplest scenario for tabs:

const TabPanel = () => (
  <Tabs>
    <Tab title="a" selected={true}/>
    <Tab title="b"/>
  </Tabs>
);

Causes an error

“React.Children.only expected to receive a single React element child”

If one removes the selected={true} or changes to selected={false} it works.

danikenan avatar Oct 23 '16 11:10 danikenan

Any way you can show more code, I'm unable to duplicate this. thanks.

dabit3 avatar Nov 07 '16 16:11 dabit3

I get the same Error if I add attribute "selected". But when I remove selected tag , It work or if I set selected={false} It work again.

jacobcyl avatar Dec 27 '16 02:12 jacobcyl

@jacobcyl Unable to reproduce this. Can you show me the code that is causing this error?

Monte9 avatar Dec 27 '16 02:12 Monte9

I found the answer! because the tag must contain a child element. We should do it like this:

<Tabs>
  <Tab>
    <SomeOtherComponent />
 </Tab>
</Tabs>

jacobcyl avatar Jan 17 '17 07:01 jacobcyl