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

Invalid Hook Call Error when Creating Custom Integration Tab for Spotlight #338

Open
DanSnow opened this issue Jan 27, 2024 · 4 comments
Open
Labels
Type: Bug-confirmed Something isn't working

Comments

@DanSnow
Copy link

DanSnow commented Jan 27, 2024

I am trying to create a custom integration tab for Spotlight. However, Spotlight bundles React into its code, causing me to encounter an "invalid hook call" error whenever I use a React component that utilizes hooks.

Environment

"@spotlightjs/spotlight": "1.2.7"

Steps to Reproduce

  1. make a simple integration plugin with component like
 function TabContent () {
    useEffect(() => { console.log('test') }, [])
    return <div />
 }

Expected Result

Successfully create an integration tab

Actual Result

image
@Shubhdeep12
Copy link
Collaborator

Hi @DanSnow can you please share the steps you used? need some more context to check what goes wrong.
Thanks

@DanSnow
Copy link
Author

DanSnow commented Jan 27, 2024

Hi @Shubhdeep12 ,

I've created a minimal reproduction at https://github.com/DanSnow/spotlight-custom-integration-issue.

Reproduction Steps:

  1. Clone this repo.
  2. Run 'yarn install'.
  3. Run 'yarn dev'.
  4. Open the page.

Expected Result:
The Spotlight button displays normally.

Actual Result:
It does not display, and there is an 'invalid hook' error in the console.

@dcramer
Copy link
Member

dcramer commented Jan 29, 2024

I'm wondering if its simple to re-export react here (though that feels dirty). Alternatively we'll have to provide some way to swap out the underlying react implementation. I'm not entirely sure what'd be cleanest here, or if theres some prior art of other folks trying to sandbox react in the same way we are.

@MisterJimson
Copy link

MisterJimson commented Feb 9, 2024

Anyway to work around this in the short term?

Edit: was able to work around by using class components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug-confirmed Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants