2016-06-20 5 views
1

내가 지금처럼 내 웹 애플리케이션 (페이지에 대한 즉, 헤더, 탐색 및 래퍼)의 구성 요소로 전체 탐색 만들려고 해요 :는 this.props.children 렌더링되지 반작용

const Navigation = React.createClass({ 
    render: function() { 
     console.log(this.props.children); 

     return (
      <div id="authenticated"> 
       <div id="header">...</div> 
       <div id="left-menu">...</div> 
       <div id="page"> 

        {this.props.childen} 

       </div> 
      </div> 
     ); 
    } 
}); 

이것은이다 나는 구성 요소를 사용 Dashboard.jsx에서 사용 방법 :

import { Navigation } from '../../components' 

const Dashboard = React.createClass({ 
    render: function() { 
     return (
      <Navigation> 
       <p>Hello</p> 
      </Navigation> 
     ); 
    } 
}); 

그것은 구성 요소 렌더링 (순자산 가치 (NAV), 헤더, ...)하지만 <p>hello</p> 렌더링하지 않습니다. 콘솔 로그에 반응 객체로 <p>hello</p>이 표시되지만 페이지에 표시되지 않습니다!

아이디어가 있으십니까?

PS : 나는 본 적이 그것은 문제가 아니다 : React ES6 | Child Component not being rendered 당신은 오타를 가지고

+2

해야 당신이있어, 'Navigation' 컴포넌트를 사용하지 않고, 당신은'AuthenticatedLayout'을 사용하고 있습니다. – nem035

+1

@ nem035 내 코드에서 올바르게 지적 해 주셔서 감사합니다. 저는 여기서 그것을 단순화하려고했습니다. 지금 수정되었습니다. – denislexic

+1

다음 단계는 DOM을 검사하여 실제로 무엇이 있는지 확인하는 것입니다. 그것은 렌더링 될 수 있지만 CSS 규칙으로 인해 보이지 않습니다. –

답변

7

, this.props.childen 제공된 코드에서 this.props.children

const Navigation = React.createClass({ 
    render: function() { 
     return (
      <div id="authenticated"> 
       <div id="header">...</div> 
       <div id="left-menu">...</div> 
       <div id="page"> 
        {this.props.children} 
       </div> 
      </div> 
     ); 
    } 
}); 

full working example

+0

오, 이런 ... 지금은 어리 석다. 감사합니다 @QoP – denislexic