【发布时间】:2017-08-07 15:34:17
【问题描述】:
我是 react 和 redux 的新手,我想创建包含两个单选按钮的组件,所以我写了这样的内容:
从 'react' 导入 React,{ PropTypes };
const renderCashRadioButtons = currentCashSelector => (
<form onClick={currentCashSelector}>
<input
type="radio"
name="cash-transaction"
value="Transcation"
onChange={value => currentCashSelector(value)}
/>
<input
type="radio"
name="cash-transfer"
value="Transfer"
onChange={value => currentCashSelector(value)}
/>
</form>
);
const CashRadioButtons = ({ currentCashSelector }) => (
<div className="container">
{renderCashRadioButtons(currentCashSelector)}
</div>
);
CashRadioButtons.propTypes = {
currentCashSelector: PropTypes.func.isRequired
};
export default CashRadioButtons;
currentCashSelector 是一个函数。当我渲染它时,它似乎不起作用。该值没有改变,我没有看到要更新的状态。你有什么想法吗?
【问题讨论】:
-
我不这么认为...我使用了另一个单选按钮组件并且它有效。但我想使用默认的html
标签: javascript reactjs radio-button stateless