0
const ChatBox = ({ messages, sendInput }) => {
<Card fluid className={theme} raised style={{ height: '100%' }}>
<ChatLog
messages={messages}
/>
<RecordInput // has internal recording state
sendInput={sendInput}
/>
</Card>
}
我的ChatBox
包含ChatLog
和RecordInput
。反应通过状态到兄弟组件
ChatLog
包含要显示的消息列表。
RecordInput
是要发送到ChatLog
的用户语音录制输入。此组件具有内部recording
状态,该状态可以是true
或false
。
我想将此recording
状态发送到ChatLog
这是一个兄弟组件。
解决方法一:我可以让ChatBox
类成分与recording
状态,并传递到两个ChatLog
和RecordInput
..但我宁愿不修改我的无功能无状态组件..
是否有另一种方式来做到这个?也许redux或做某种克隆?