From d6055779166cc02239d7f9de5968f77a6baf6eed Mon Sep 17 00:00:00 2001 From: Scott Koenig Date: Thu, 28 Jun 2018 16:01:28 -0400 Subject: [PATCH] [docs] Link RootRef in the FAQ (#12005) * reference component in FAQ * Update faq.md --- docs/src/pages/getting-started/faq/faq.md | 36 +---------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/docs/src/pages/getting-started/faq/faq.md b/docs/src/pages/getting-started/faq/faq.md index 9b94c69906cad5..5cb03e0c512586 100644 --- a/docs/src/pages/getting-started/faq/faq.md +++ b/docs/src/pages/getting-started/faq/faq.md @@ -90,41 +90,7 @@ export default withTheme()(withStyles(styles)(Modal)); ## How can I access the DOM element? -You can use the `ref` property in conjunction with the [`findDOMNode()`](https://reactjs.org/docs/react-dom.html#finddomnode) React API. Or you can [use an abstraction](https://github.com/facebook/react/issues/11401#issuecomment-340543801): - -```jsx -import React from 'react'; -import ReactDOM from 'react-dom'; -import PropTypes from 'prop-types'; - -class RootRef extends React.Component { - componentDidMount() { - this.props.rootRef(ReactDOM.findDOMNode(this)) - } - - componentWillUnmount() { - this.props.rootRef(null) - } - - render() { - return this.props.children - } -} - -RootRef.propTypes = { - children: PropTypes.element.isRequired, - rootRef: PropTypes.func.isRequired, -}; - -export default RootRef; -``` - -Usage: -```jsx - { console.log(node) }}> - - -``` +Wrap the component with the [``](/api/root-ref) helper. ## Why are the colors I am seeing different from what I see here?