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

useSWRSubscription key doesnt deconstruct array #2548

Closed
imownbey opened this issue Apr 6, 2023 · 3 comments · Fixed by #2550
Closed

useSWRSubscription key doesnt deconstruct array #2548

imownbey opened this issue Apr 6, 2023 · 3 comments · Fixed by #2550
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@imownbey
Copy link

imownbey commented Apr 6, 2023

Bug report

Description / Observed Behavior

When using an array key the key that is passed to the subscribe function is a string and not an array

Expected Behavior

I expect it to be deconstructed similar to is shown under "Usage" here https://swr.vercel.app/docs/subscription

Repro Steps / Code Example

  const key = "a key";
  const { data } = useSWRSubscription(["key", key], (passedKey, { next }) => {
    passedKey === '@"key","a key",' // returns true
    return () => {};
  });

https://codesandbox.io/s/relaxed-silence-h556kz?file=/src/App.js

Additional Context

2.1.2

@promer94 promer94 added the bug Something isn't working label Apr 7, 2023
@promer94
Copy link
Collaborator

promer94 commented Apr 7, 2023

we should pass original key here instead of serialized key

const dispose = subscribe(key, { next })

@promer94 promer94 added the good first issue Good for newcomers label Apr 7, 2023
@Zheaoli
Copy link
Contributor

Zheaoli commented Apr 7, 2023

I would like to take this issue

@crutch12
Copy link

crutch12 commented Jan 19, 2024

By the way
Could we pass originKey in onError/onSuccess callback?
Now it accepts only serialized key, it's terrible.

@Zheaoli @promer94

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants