2016-10-05 4 views
0

これはどこでもこのようなことは何も見ていないので、これは一般的な質問です。 下の例のような親コンポーネントがあり、親で子の子をレンダリングしていた場合、親でgetParentComponent(子)メソッドを作成する以外は、可能な場合はどうすればよいでしょうか。 子レンダリングが呼び出されたときに、子コンテンツが自動的に挿入されることはありますか?親を拡張して親のレンダリングメソッドを使用するネイティブ応答

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> 
     ) 
    } 
} 

答えて

0

親クラスは、性質上、extendsというクラスに関する知識はありません。そう、いいえ。 MDN extends documentation詳細

refsは、childrenのようにComponentpropsにアクセスするのに役立ちます。

+0

ありがとうございました。病気は解決策のいくつかの並べ替えで行くと私は私の答えで再投稿されます。しかし、あなたが送った書類をチェックしたところ、あなたは正しいです。ありがとうございました – TheMan68

関連する問題