0

I'm not an expert on react, and I can't find a way to do this, but how can I create a custom component that I could be used like this:

<MyComponent>
   <View></View>
   <View></View>
        ...
</MyComponent>

Where, inside I could place whatever I want. The MyComponent could be:

<View>
   <View> 
   </View> <-- Header 
   <View> 
   </View> <-- Content
     Childs, the two Views, would be placed here.
   <View>
   <View>
   </View> <-- Fotter
</View>

Is this possible to achieve?

Thanks very much in advance :)

2
  • It seems unclear what you are trying to accomplish, Can you explain what your trying to accomplish? Commented Feb 10, 2020 at 19:47
  • I want to create the MyComponent and use it by <MyComponent><MyComponent/> and place any childs components I need Commented Feb 10, 2020 at 19:51

1 Answer 1

2

Change your MyComponent like this

<View>
   <View> 
   </View> <-- Header 
   <View> 
   </View> <-- Content

    {this.props.children}

   <View>
   </View> <-- Footer
</View>
Sign up to request clarification or add additional context in comments.

2 Comments

thank you, I tried this, but I guess I did not try hard enough
You're welcome. I just solved a bug that took my 13 hours of non-stop working.Enjoy your life haha.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.