也没到那么搞中间层 form 的地步,你就在
`
const Parent = (props)=>{
const [pState,setPState] = useState({});
function handlePStateChange(InputName, value){
setPState({
...pState,
[InputName]:value,
})
}
return (
<div>
<Child id={'1'} handleChange={handlePStateChange} />
....
<Child id={'n'} handleChange={handlePStateChange} />
</div>
)
}
const Child = (props) =>{
const [input, setInput] = useState();
return (
<Input onChange={(e)=>props.handleChange(
props.id, e.target.value)} />
)
}
`