Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Question regarding children constraint #1

Open
sospedra opened this issue Sep 7, 2017 · 2 comments
Open

Question regarding children constraint #1

sospedra opened this issue Sep 7, 2017 · 2 comments

Comments

@sospedra
Copy link

sospedra commented Sep 7, 2017

We all know that TouchableNativeFeedback only support one single child. But, why don't handle it and wrap the children into a View?

render () {
  // changing some pieces of your render

  // notice the `toArray`
  children = React.Children.toArray(children);

  // notice the View wrapping the children
  return <TouchableComponent>
    <View>{children}</View>
  </TouchableComponent>
}

Just wondering why don't do this approach :)

@b-asaf
Copy link

b-asaf commented Nov 22, 2017

from docs:

// Good
<Touchable>
  <Child>
    <GrandChild />
    <GrandChild />
  </Child>
</Touchable>

// Bad
<Touchable>
  <Child />
  <Child />
</Touchable>

in the good example:
<View> -> <Child>...</Child>
{children} -> <GrandChild /><GrandChild />

@Cnordbo
Copy link

Cnordbo commented Dec 10, 2018

Because you should be in control yourself :)

Adding a wrapper to your element could have a major impact on your layout, which would introduce you to a lot of "why doesnt this work" bugs, without seeing the error in your own code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants