Sorry, this question is maybe duplicated and answered here, but do not solve my problem.
I want to allow only numbers in my input outside return and in the nonstate component and inside props.
My code.js
const General = props => (
<Row>
<Col>
<Form.Item>
<Input />
</Form.Item>
</Col>
</Row>
)
export default General
>Solution :
try this please.
State is here.
const [obj, setobj] = useState({ number: 0 });
onChange function is here.
const onChangeData = (event, type, value) => {
let data = null;
data = value;
setobj({ ...obj, [type]: data })
}
input function is here.
<input
type="number"
value={obj.number}
onChange={(event) => this.onChangeData("number",event.target.value)} />