Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip no longer works other components, just Buttons #1021

Open
tomzweb opened this issue Oct 20, 2022 · 3 comments
Open

Tooltip no longer works other components, just Buttons #1021

tomzweb opened this issue Oct 20, 2022 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@tomzweb
Copy link
Contributor

tomzweb commented Oct 20, 2022

On the latest version (0.34.1) of big design, using a Text or Badge component no longer works as a trigger for the Tooltip. I upgraded from 0.30.2 which worked fine. However, 0.34.1 now returns the below warning and no tooltip is displayed.

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

Check the render method of `Reference`._ 

To reproduce the bug, use the Text or Badge component as the trigger:

<Tooltip placement='auto' trigger={<Text>Hello</Text>}>
   HELLO FROM TOOLTIP
</Tooltip>

I would expect no error and the tooltip to show as it previously did.

However, using a Text as a trigger resolves the warning and displays the tooltip.

@chanceaclark
Copy link
Contributor

Thanks @tomzweb for reporting this!

On the surface, it looks like we just need to forward the ref to our Text component.

I upgraded from 0.30.2 which worked fine.

This sounds like a transient dependency caused it to break. I tried to replicate this in a CodeSandbox and was still getting the same issue in 0.30.2 🤔 If you could replicate it working in a CodeSandbox, that'd be super helpful to understand the underlying issue of why it was working before 🙏

@chanceaclark chanceaclark added bug Something isn't working good first issue Good for newcomers labels Oct 20, 2022
@tomzweb
Copy link
Contributor Author

tomzweb commented Oct 21, 2022

@chanceaclark 0.30.2 working here: https://codesandbox.io/s/silent-rain-kxqcdb?file=/src/App.tsx using React 18 and styled-components 5.3.6. Though I can confirm 0.30.2 was also working on our project using React 17 and styled-components 5.3.5

And 0.34.1 here: https://codesandbox.io/s/amazing-joana-z5th59?file=/src/App.js which is showing the error in the console log.

@gbspecapedra
Copy link

gbspecapedra commented Jun 12, 2023

Same issue here using a Badge or Text component as the trigger.

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

Check the render method of `Reference`.
Badge@http://localhost:2000/static/js/bundle.js:29870:11
"react": "^18.2.0",
"@bigcommerce/big-design": "^0.36.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Development

No branches or pull requests

3 participants