ReactJS - 'valueLink' is deprecated set `value` and `onChange` instead

前端 未结 3 960
甜味超标
甜味超标 2021-02-10 13:50

I am currently learning ReactJS following a tutorial by the excellent Wes Bos, however I have reached a section regarding 2 way data binding and it seems the method Wes is teach

3条回答
  •  执笔经年
    2021-02-10 14:22

    Ok so the issue I am having is with "valueLink", console says I should be using 'value' and 'onChange' in its place. Could anyone help me out with this issue, seems a lot of the learning involved with react is trying to stay on top of all the deprecated elements!

    Value Link is the design pattern, Facebook cannot deprecate it. They will just remove their implementation of that pattern from the React core. Read through this article for explanation about the pattern:

    https://medium.com/@gaperton/managing-state-and-forms-with-react-part-1-12eacb647112#.5o63wmy72

    No easy/messy 2-way data binding with modern React!

    You don't have to use their implementation of value links (it's very limited anyway). And you don't have to write everywhere these stupid callbacks either. This one, which is presented in the article, is way more powerful.

    https://www.npmjs.com/package/valuelink

提交回复
热议问题