summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/README.md b/README.md
index cc716b5..3b19fe6 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,29 @@ In addition to `minHeight`, you can force `TextareaAutosize` to have a minimum n
<TextareaAutosize rows={3} /> // minimun height is three rows
```
+#### Refs to DOM nodes
+In order to manually call `textarea`'s DOM element functions like `focus()` or `blur()`, you need a ref to the DOM node.
+
+You get one by using the prop `ref` and `ReactDOM.findDOMNode` as shown in the example below.
+
+NOTE: As `TextareaAutosize` is not a native React component (`input`, `div`, `textarea` ...), `ref` will return you the instance of the class. You have to use `ReactDOM.findDOMNode` to get a pointer to the DOM element.
+
+```jsx
+class Form extends React.Component {
+ componentDidMount() {
+ this.textarea.focus();
+ }
+
+ render() {
+ return (
+ <TextareaAutosize
+ ref={(ref) => { this.textarea = ReactDOM.findDOMNode(ref); }}
+ />
+ );
+ }
+}
+```
+
## Browser Compatibility
| Chrome | Firefox | IE | Safari | Android |
| ------------- | ------------- | ----- | ------ | ------- |