kdchang / reactjs101

從零開始學 ReactJS(ReactJS 101)是一本希望讓初學者一看就懂的 React 中文入門教學書,由淺入深學習 ReactJS 生態系 (Flux, Redux, React Router, ImmutableJS, React Native, Relay/GraphQL etc.)。
https://www.gitbook.com/book/kdchang/react101/details
Other
4.31k stars 1.22k forks source link

Ch04 Refs 與表單處理 #59

Open yachtingchen opened 7 years ago

yachtingchen commented 7 years ago

"Refs 與表單處理"章節中提到的ref用法,在react官網上https://facebook.github.io/react/docs/refs-and-the-dom.html 已經不建議使用了,節錄如下:

If you worked with React before, you might be familiar with an older API where the ref attribute is a string, like "textInput", and the DOM node is accessed as this.refs.textInput. We advise against it because string refs have some issues, are considered legacy, and are likely to be removed in one of the future releases. If you're currently using this.refs.textInput to access refs, we recommend the callback pattern instead.