反応:親と子のコンポーネント間のUSENTの同期データ
1120 ワード
親:
const Parent = () => {
const [text, setText] = useState('')
const input = (value) => {
setText(value)
}
return (
<View style={styles.contianer}>
<Child input={input} />
<Text style={{padding: 10, fontSize: 42}}>
{text}
</Text>
</View>
)
}
子const Child = (params) => {
const [storage, setValue] = useLocalStorage({});
const [text, setText] = useState('')
const handleOnChange = (text) => {
setText(text)
params.input(text)
}
return(
<View style={styles.seacrbar} >
<FontAwesomeIcon style={styles.searchIcon} icon={ faSearch } />
<TextInput
style={styles.input}
placeholderTextColor="#3f4652"
placeholder="Search Coin Pairs"
onChangeText={handleOnChange}
/>
</View>
)
}
Reference
この問題について(反応:親と子のコンポーネント間のUSENTの同期データ), 我々は、より多くの情報をここで見つけました https://dev.to/vatheara/react-sync-data-of-usestate-between-parent-and-child-component-h9eテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol