J
J
jedifa2021-07-20 21:42:15
React
jedifa, 2021-07-20 21:42:15

Is it ok to put setState in another component's prop?

I have a question, please tell me, for example, in the app component there is some kind of State, for example, is it normal to pass setTest to another component through props? const [test, setTest] = useState('');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-07-20
@jedifa

Quite. For example, for many components, not an Event, but a new value is passed to the onChange callback, and it is convenient to pass setValue there. The main thing is that that other component does not call it after unmounting the hook-owning component

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question