0

This is a general question as I've not seen anything like this anywhere. So if I have a parent component like the examples below and I was to render the children of the child in the parent how could I do this if its possible (other than making a getParentComponent(children) method in the parent). Is there a was that when the child render gets called that the child content automatically gets inserted?

import React, {Component} from 'react';
import {View} from 'react--native;

class CustomView extends Component {
    render() {
        return (
            <View style={styels.customStyle}>
                // this is where I want to render my child content
            </View>
        )
    }
}

import React, {Component} from 'react';
import {CustomView} from 'somewhere;

class ChildView extends CustomView {
    render() {
        return (
            <View style={styels.childStyle}>
                // take this view and all the content with in and render it in the parent render
            </View>
        )
    }
}
TheMan68
  • 1,429
  • 6
  • 26
  • 48

1 Answers1

0

By nature, a parent class has no knowledge of any class that extends it. So, no. MDN extends documentation explains more.

Otherwise, refs might help you get access to a Component's props, like children.

chandlervdw
  • 3,197
  • 4
  • 19
  • 21
  • Thank you very much. Ill have a go at coming up with some sort of solution and i will repost in my answer. But I checked the documentation you sent and you are right. Thank you – TheMan68 Oct 10 '16 at 03:53