react-hook-form / documentation

📋 Official documentation
http://react-hook-form.com
MIT License
726 stars 1.04k forks source link

issue: error in docs #1025

Open nicitaacom opened 1 year ago

nicitaacom commented 1 year ago

Codesandbox/Expo snack

https://github.com/nicitaacom/acc2-react_hook_form_with_useref

Version Number

7.47.0

Steps to reproduce and reproduce example

I tried do it with codesandbox but got 2 errors image

It even don't let me type in terminal image

Expo snack don't let me import respository also there are no terminal at all (I wanted to create clear next app to create minimal reproduce example but since I didn't found it I decided to import repository) image




Minimal reproduce example

please check it out - https://github.com/nicitaacom/acc2-react_hook_form_with_useref

  1. git clone https://github.com/nicitaacom/acc2-react_hook_form_with_useref
  2. pnpm i
  3. pnpm dev
  4. It should work like so: when I press esc it discard changes I made when I press enter it apply changes I made

Now to discard changes I use event listener on esc press and it doesn't work (I mean I ref is null - check console log to make sure that is null - so I that's the isse - without ref its no way to realize functionality I described above)

Expected behaviour

https://www.react-hook-form.com/faqs/#Howtosharerefusage

This example lies and firstNameRef returns null if you console.log it

It makes impossibe to use ref to add event listener to ref (or set focus state)

What browsers are you seeing the problem on?

Chrome

Relevant log output

'inputRef.current - ' null