react LinkedStateMixin 已经过时

前端之家收集整理的这篇文章主要介绍了react LinkedStateMixin 已经过时前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

页面会报告已经警告

Warning: `valueLink` prop on `input` is deprecated; set `value` and `onChange` instead.
Note: LinkedStateMixin is deprecated as of React v15. The recommendation is to explicitly set the value and change handler,instead of using LinkedStateMixin.

参考文档:https://facebook.github.io/react/docs/two-way-binding-helpers.html

DEMO 代码

npm install react-addons-linked-state-mixin –save

import React from 'react';
import Reflux from 'reflux'
var ReactDOM = require('react-dom');
import LinkedStateMixin from 'react-addons-linked-state-mixin'
var HelloWorld = React.createClass({
    mixins: [LinkedStateMixin],getInitialState: function() {
        return {message: 'Hello!'};
    },render: function () {
        return <div>
            {this.state.message}
            <input type="text"  valueLink={this.linkState('message')}/>

        </div>
    }
})
ReactDOM.render(
    <HelloWorld />,document.getElementById('J_contentContainer'))

猜你在找的React相关文章