实现React组件通信的正确方法父->子->子->父

问题描述 投票:0回答:1

我对React很陌生,一直在徘徊什么是在这种情况下实现组件通信的正确方法。

假设我希望<Form>了解每个<TextInput>值。因此,<TextInput>应该能够将其值onChange设置为其父级<Form>

实现它的正确方法是什么,或者可能更多?没有Redux。组件投影应该以相同的方式进行。

<Form>
    <FormGroup>
        <TextInput/>
    <FormGroup>
</Form>
reactjs nested components parent-child communication
1个回答
0
投票

如何使用反应上下文?

https://reactjs.org/docs/context.html

© www.soinside.com 2019 - 2024. All rights reserved.