将数字传递给组件

Passing a number to a component

我正在尝试将数字传递给 React 组件,但它被解析为字符串 (jsfiddle)。我如何让 React 明白我传递的是一个数字?我应该将字符串转换为组件中的数字吗?

var Rectangle = React.createClass({
   
    render: function() {

        return <div>
            <div>{this.props.intValue + 10}</div>
            <div>{this.props.stringValue + 10}</div>
        </div>;
    }
});
 
React.render(<Rectangle intValue="10" stringValue="Hello" />
    , document.getElementById('container'));
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>

<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

似乎在整数的情况下(实际上对于字符串也是如此)我应该像这样通过 {} 传递数字:

React.render(<Rectangle intValue={10} stringValue={"Hello"} />, document.getElementById('container'));

您可以使用:

<MyComponent param1={10} param2={20} />

或者:

<MyComponent {...{param1: 10, param2: 20}} />