You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.1 KiB
1.1 KiB
id | title | layout | permalink | prev | next |
---|---|---|---|---|---|
references-to-components | References to Components | tips | references-to-components.html | expose-component-functions.html | children-undefined.html |
If you're using React components in a larger non-React application or transitioning your code to React, you may need to keep references to components. React.render
returns a reference to the mounted component:
var myComponent = React.render(<MyComponent />, myContainer);
Keep in mind, however, that the JSX doesn't return a component instance! It's just a ReactElement: a lightweight representation that tells React what the mounted component should look like.
var myComponentElement = <MyComponent />; // This is just a ReactElement.
// Some code here...
var myComponentInstance = React.render(myComponentElement, myContainer);
Note:
This should only ever be used at the top level. Inside components, let your
props
andstate
handle communication with child components, and only reference components via refs.