2016-10-05 2 views
0

어디서나이 같은 것을 보지 못했기 때문에 일반적인 질문입니다. 그래서 아래 예제와 같은 상위 구성 요소가 있고 부모에서 자식의 자식을 렌더링하는 경우 가능한 경우 (부모에서 getParentComponent (children) 메서드를 만드는 것 외에) 어떻게 할 수 있습니까? 자식 렌더링이 호출되면 자식 컨텐츠가 자동으로 삽입 되는가?상위 확장 및 상위 렌더링 방법 사용 네이티브 반응

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 자세한 내용.

그렇지 않으면 refschildren과 같이 Componentprops에 액세스하는 데 도움이 될 수 있습니다.

+0

대단히 감사합니다. 나는 일종의 해결책을 생각해 내고 대답을 재발행 할 것이다. 그러나 당신이 보낸 문서를 확인하고 당신이 옳다. 고맙습니다 – TheMan68

관련 문제