-
Hello, I have the following component that takes
And, I have a simple test that wants to check whether the component rendered or not
Now, the problem is that I don't know how to pass Can anyone help? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
maybe this section will be helpful: https://react-hook-form.com/advanced-usage#TestingForm |
Beta Was this translation helpful? Give feedback.
-
For future reference, the solution to the question above has three parts. First, instead of passing
Second, you need to refactor the nested component to access the form context as follow:
Third, in your test file, you need to wrap the
|
Beta Was this translation helpful? Give feedback.
For future reference, the solution to the question above has three parts.
First, instead of passing
control
down as a prop to a nested component, you can access the form context with the use ofuseFormContext
. Documentation here.Second, you need to r…