Skip to content

Commit ac00d0d

Browse files
committed
doc(CopyToClipboard): Update example.
1 parent 4efdaa9 commit ac00d0d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/copy-to-clipboard/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class Demo extends React.Component {
5555
super(props);
5656
this.state = {
5757
copyText: "生亦何欢,死亦何苦"
58-
}
58+
};
59+
this.input = React.createRef();
5960
}
6061
onChange(e){
6162
this.setState({
@@ -69,7 +70,7 @@ class Demo extends React.Component {
6970
<div>
7071
<Input
7172
type="text"
72-
ref={(input) => this.input = input}
73+
ref={this.input}
7374
value={copyText}
7475
onChange={this.onChange.bind(this)}
7576
/>
@@ -84,7 +85,7 @@ class Demo extends React.Component {
8485
this.setState({ message: '' });
8586
}, 2000);
8687
});
87-
ReactDOM.findDOMNode(this.input).querySelector('input').select();
88+
this.input.current.inputRef.current.select();
8889
}}
8990
>
9091
<Button type="primary">点击复制</Button>

0 commit comments

Comments
 (0)