J'ai le composant suivant ( radioOther.jsx):
 'use strict';
 //module.exports = <-- omitted in update
   class RadioOther extends React.Component {
     // omitted in update 
     // getInitialState() {
     //    propTypes: {
     //        name: React.PropTypes.string.isRequired
     //    }
     //    return {
     //       otherChecked: false
     //   }
     // }
     componentDidUpdate(prevProps, prevState) {
         var otherRadBtn = this.refs.otherRadBtn.getDOMNode();
         if (prevState.otherChecked !== otherRadBtn.checked) {
             console.log('Other radio btn clicked.')
             this.setState({
                 otherChecked: otherRadBtn.checked,
             });
         }
     }
     onRadChange(e) {
         var input = e.target;
         this.setState({
             otherChecked: input.checked
         });
     }
     render() {
         return (
             <div>
                 <p className="form-group radio">
                     <label>
                         <input type="radio"
                                ref="otherRadBtn"
                                onChange={this.onRadChange}
                                name={this.props.name}
                                value="other"/>
                         Other
                     </label>
                     {this.state.otherChecked ?
                         (<label className="form-inline">
                             Please Specify:
                             <input
                                 placeholder="Please Specify"
                                 type="text"
                                 name="referrer_other"
                                 />
                         </label>)
                         :
                         ('')
                     }
                 </p>
             </div>
         )
     }
 };
Avant d'utiliser ECMAScript6, tout allait bien, maintenant je reçois 1 erreur, 1 avertissement et j'ai une question de suivi:
Erreur: Uncaught TypeError: Impossible de lire la propriété 'otherChecked' de null
Attention: getInitialState a été défini sur RadioOther, une classe JavaScript simple. Ceci n'est pris en charge que pour les classes créées à l'aide de React.createClass. Vouliez-vous plutôt définir une propriété d'état?
Quelqu'un peut-il voir où se trouve l'erreur, je sais que c'est dû à l'instruction conditionnelle dans le DOM mais apparemment je ne déclare pas sa valeur initiale correctement?
Dois-je rendre getInitialState statique
Où est l'endroit approprié pour déclarer mes proptypes si getInitialState n'est pas correct?
METTRE À JOUR:
   RadioOther.propTypes = {
       name: React.PropTypes.string,
       other: React.PropTypes.bool,
       options: React.PropTypes.array }
   module.exports = RadioOther;
@ssorallen, ce code:
     constructor(props) {
         this.state = {
             otherChecked: false,
         };
     }
produit "Uncaught ReferenceError: this is not defined", et en dessous corrige que
     constructor(props) {
     super(props);
         this.state = {
             otherChecked: false,
         };
     }
mais maintenant, cliquer sur l'autre bouton produit maintenant une erreur:
Uncaught TypeError: Cannot read property 'props' of undefined
onChange={this.onRadChange},thisne fait pas référence à l'instance lorsqu'elleonRadChangeest appelée. Vous devez callbacks bind dansrenderou le faire dans le constructeur:onChange={this.onRadChange.bind(this)}.