<Parent> /* event to fetch all refs value and submit */
<Child>
<stateless function />/*this is all the refs sittin*/
</Child>
</Parent>
親がどのように子どもからすべての参照を取得できるのか分かりませんか?事前に感謝しますreactjs親イベントのすべての子参照を取得します(handleSubmit)
<Parent> /* event to fetch all refs value and submit */
<Child>
<stateless function />/*this is all the refs sittin*/
</Child>
</Parent>
親がどのように子どもからすべての参照を取得できるのか分かりませんか?事前に感謝しますreactjs親イベントのすべての子参照を取得します(handleSubmit)
私はそれがおそらく遅すぎるとあなたはすでに答えを知っていた。 あなたが必要とするのは、子供たちへの参照である "ref"です。 これを読むようなExposing DOM Refs to Parent Components
何か:
class Parent extends React.Component {
render() {
return (
<div>
// this line will create a reference to the input text,
// inside the Child Component
// for example, if you want to get the value
// you can access `this.input.value`
<Child inputRef={(refToChild) => this.input = refToChild} />
</div>
)
}
}
class Child extends React Component {
render() {
return (
<form>
// this line will call the Parent's function,
// creating a reference to the input text.
<input type="text" ref={props.inputRef} />
</form>
)
}
}
を、あなたは、例えば、入力したコードを追加し、outputratherあなた構造よりも期待できます。 –