Avoid using string references
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。
ID: tsx-react/no-string-refs
Language: TypeScript
Severity: Warning
Category: Best Practices
Description
String references are a legacy feature of React. Use a reference callback instead.
Non-Compliant Code Examples
var Hello = createReactClass({
render: function() {
return <div ref="hello" a="foo" />;
}
});
var Hello = createReactClass({
render: function() {
return <div ref="hello">Hello, world.</div>;
}
});
var Hello = createReactClass({
componentDidMount: function() {
var component = this.refs.hello;
// ...do something with component
},
render: function() {
return <div ref="hello">Hello, world.</div>;
}
});
Compliant Code Examples
var Hello = createReactClass({
componentDidMount: function() {
var component = this.hello;
// ...do something with component
},
render() {
return <div ref={(c) => { this.hello = c; }}>Hello, world.</div>;
}
});
Seamless integrations. Try Datadog Code Analysis