2016-06-14 5 views
0

'LinkedStateMixin'を使用せずに次のコードを書き直すにはどうすればよいですか? React 15.0にアップグレードしているので、この機能は廃止されました。React 15.1.0の反応アドオン機能の書き換え

reactMixin(LoginView.prototype, React.addons.LinkedStateMixin); 


<div className='form-group'> 
    <input type='text' 
    className='form-control input-lg' 
    valueLink={this.linkState('email')} 
    placeholder='Email' /> 
</div> 
<div className='form-group'> 
    <input type='password' 
    className='form-control input-lg' 
    valueLink={this.linkState('password')} 
    placeholder='Password' /> 
</div> 

上記のコードは、使用されている状態で、状態を管理するためにReduxを使用しています。

答えて

3

自分で状態を管理できます。 babel/es6を使っていますか?

class MyForm extends React.Component { 
    state = {} 

    emailChanged = (e) => { 
     this.setState({ email: e.target.value }); 
    } 

    passwordChanged = (e) => { 
     this.setState({ password: e.target.value }); 
    } 

    render() { 
     const { email, password } = this.state; 
     return (
     <form> 
      <div className='form-group'> 
      <input type='text' 
       className='form-control input-lg' 
       value={email} 
       placeholder='Email' 
       onChange={this.emailChanged} /> 
      </div> 
      <div className='form-group'> 
       <input type='password' 
       className='form-control input-lg' 
       value={password} 
       placeholder='Password' 
       onChange={this.passwordChanged} /> 
      </div> 
     </form> 
     ); 
    } 
} 

例:http://www.webpackbin.com/EJjZTnu4Z

関連する問題