現在、Reactベースのアプリ開発をしています。
多くの入門書やページでは、子コンポーネントから親コンポーネントのstateを変更する際、
TypeScript
1const ComponentA = () => { 2 const [value, setValue] = useState<string>(); 3 4 handleValue = (value: string) => { 5 setValue(value); 6 } 7 8 return( 9 <ComponentB handleValue={handleValue} /> 10 ); 11} 12 13const ComponentB = (props: {handleValue: (value: string} => void}) => { 14 // 略 15}
のように値をセットするだけの関数を別に定義しているものが大抵なのですが、
set関数自体を渡すことになにか問題があるのでしょうか?
https://ja.stackoverflow.com/questions/94998
以下ご対応ください。
https://teratail.com/help#posted-otherservice
