question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug report

It seems I can’t set a ref anymore on <Form /> components.

I looked into <ReactFinalForm /> component and it doesn’t seem to forward the ref.

Maybe using useImperativeHandle to expose the form api would be a solution?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

27reactions
crobinson42commented, Jun 6, 2019

FYI - this is a breaking change that needs to be fixed in a patch version ASAP.

In v5 this works:

<Form
  onSubmit={() => this.form.form.reset()}
  ref={el => (this.form = el)}
/>

and no longer works in v6 due to the ref not being forwarded by react-final-form

4reactions
crobinson42commented, Jun 6, 2019

I have dozens of components that use this:

<Form
        ....
        ref={el => (this.form = el)}
/>

And since upgrading to v6 of react-final-form I’m getting this Warning everywhere:

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Forwarding Refs - React
Ref forwarding is a technique for automatically passing a ref through a component to one of its children. This is typically not necessary...
Read more >
How to use React's forwardRef function - Felix Gerschau
forwardRef is a helper function from React that allows us to forward a component's ref to another one. This tutorial will teach what...
Read more >
Using forwardRef in React to clean up the DOM
React forwardRef is a method that allows parent components pass down (i.e., “forward”) refs to their children. Using forwardRef in React ...
Read more >
forwardRef/createRef - React TypeScript Cheatsheets
forwardRef /createRef ... Check the Hooks section for useRef . ... ));. Side note: the ref you get from forwardRef is mutable so...
Read more >
How can I use forwardRef() in React? - Stack Overflow
The forwardRef api, (coupled with the useImperativeHandle hook) lets you customize how and where your refs are placed inside your custom ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found