- 꼭 아래 script를 html script로 추가해야 작동합니다.
- https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js
- https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-with-addons.js
class Child extends React.Component {
componentDidMount() {
this.props.onRef(this)
}
componentWillUnmount() {
this.props.onRef(null)
}
method() {
alert('do stuff')
}
render() {
return Hello World!
}
}
// Any higher-order component (HOC), for examle:
// withStyles https://github.com/kriasoft/isomorphic-style-loader
// connect https://github.com/reactjs/react-redux
// etc.
class EnhancedChild extends React.Component {
render() {
return
}
}
class Parent extends React.Component {
onClick = () => {
this.child.method() // do stuff
};
render() {
return (
(this.child = ref)} />
);
}
}
ReactDOM.render(, document.getElementById('root'))
댓글
댓글 쓰기