How to transfer props to reaction v0.13?

I am trying to find out how to react to my first javascript project and how to start creating very simple code that adds two numbers entered into a textbox. The result is redrawn as the number is entered. This helped me react v0.11.

var App = React.createClass({

    mixins: [React.addons.LinkedStateMixin],

    getInitialState: function() {
        return {
            payment: 0,
            payment2: 0
        };
    },
    render: function() {
        var total = parseInt(this.state.payment, 10) +
                    parseInt(this.state.payment2, 10);
        return (
            <div>
                <Payment {...this.props} valueLink={this.linkState('payment')}/><span>+</span>
                <Payment {...this.props} valueLink={this.linkState('payment2')}/><span>=</span>
                { total }
            </div>
        );
    }

});


var Payment = React.createClass({

    render: function() {
        return this.transferPropsTo(
            <input type="text" />
        );
    }

});

React.render(
 <App />,
 document.getElementById('app')
);

      

However, it looks like the transferPropsTo () function was removed in v0.13. How to make the equivalent in the latest version.

+3


source to share


1 answer


You can pass {...this.props}

in the input tag:

 var Payment = React.createClass({
   render: function() {
     return (
       <input type="text" {...this.props} />
     );
   }
});

      



This is where the JSX attribute is used.

+6


source







All Articles