문제

If I have the components structured as below in ReactJS

<Root clickHandler={this.handleClick}>
   <Parent>
     <Children></Children>
   </Parent>
</Root>

can I have access to the 'Root' components clickHandler using this.props on the 'Children' component or does the clickHandler needs to be passed all the way from Root to Parent to Children in order for the Children component to have access to it.

도움이 되었습니까?

해결책

Documentation at: http://facebook.github.io/react/tips/communicate-between-components.html says that whatever from Parent or Root you want to access in the Child, it needs to be passed as props

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top