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

React experimental concurrent issue #494

Closed
bbenezech opened this issue Jul 1, 2020 · 8 comments · Fixed by #510 or #777
Closed

React experimental concurrent issue #494

bbenezech opened this issue Jul 1, 2020 · 8 comments · Fixed by #510 or #777

Comments

@bbenezech
Copy link

facebook/react#18838

I tried swr with suspense mode, with a recent 0.0.0-experimental-7f28234f8 react build, and I get errors Can't perform a React state update on a component that hasn't mounted yet for each useSWR call.

This indicates that there's a side-effect spawned during render, that then asynchronously tries to set state when the response comes back. E.g. kick off a request and then setState with the result. It's a common mistake when implementing Suspense.

This should be done in useEffect.

Does this make sense to you?

Unfortunately I can't help you a lot more than that, it doesn't help to where the error comes exactly.

@bradenhs
Copy link

bradenhs commented Jul 8, 2020

I'm seeing the exact same issue. Looks like this is just a warning and there isn't (as far as I can tell) anything user facing that actually breaks b/c of this. Would still be nice to see this resolved of course :)

@huozhi
Copy link
Member

huozhi commented Jul 8, 2020

hi @bbenezech @bradenhs
I tried the experiemental build locally with suspense demo (in swr examples folder). I didn't see any warnings logging out in the console. the console tab is slient.

image

could you provide more details about the repro steps or the code snippet? codesandbox link will be great. and some related info like swr version. thanks!

@bradenhs
Copy link

bradenhs commented Jul 8, 2020

Screen Shot 2020-07-08 at 12 45 58 PM

Here's a codesandbox link: https://codesandbox.io/s/quirky-burnell-cn51p?file=/src/App.tsx. The problem only appears when there are multiple useSWR hooks used. Also, the warning doesn't appear on the initial load of the page. You have to refresh the codesandbox preview specifically for some reason (I'm guessing that's a codesandbox specific issue though since locally I see the warning on the initial load).

@huozhi
Copy link
Member

huozhi commented Jul 9, 2020

@bradenhs thanks for the code example, I filed a PR to fix it. it will be released in next patch or minor version. and thanks again all of you for the reporting this issue! 👍

@huw
Copy link

huw commented Aug 8, 2020

@huozhi This is still occurring on 0.3.0

@jakst
Copy link

jakst commented Nov 16, 2020

@huozhi https://codesandbox.io/s/frosty-lamarr-xzmq6 the error is still present in 0.3.8. Would you consider reopening?

@huozhi huozhi reopened this Nov 17, 2020
promer94 added a commit to promer94/swr that referenced this issue Nov 17, 2020
@promer94 promer94 mentioned this issue Nov 17, 2020
shuding pushed a commit that referenced this issue Nov 17, 2020
* fix #494

* add comment

* rename to initialMountedRef
@huozhi
Copy link
Member

huozhi commented Nov 19, 2020

@huw @jakst 0.3.9 should fix this issue. could you bump version to try again? thanks!

@jakst
Copy link

jakst commented Nov 19, 2020

Works 👍 Thanks!

shuding added a commit that referenced this issue Dec 16, 2020
* 0.3.8

* replace rIC with rAF (#744)

* Fix race condition when calling mutate synchronously (#735)

* fix race condition when calling mutate synchronously

* fix test

* add comment

* fix code reviews

* refactor: support SSR in Deno (#754)

* refactor: support SSR in Deno

* refactor: improve Deno determining

* Add @ts-ignore

Co-authored-by: Shu Ding <[email protected]>

Co-authored-by: Shu Ding <[email protected]>

* fix eslint error (#768)

* Fix `mutateCallback` types (#745)

* Fix `mutateCallback` types

* WIP

* Add CodeSandbox CI (#769)

* add CodeSandbox CI

* add new line

* fix install cmd

Co-authored-by: Paco <[email protected]>

* dispatch's payload type is actionType and run lint (#772)

* chore: payload is actionType

* chore: move a ts-ignore comment

* Fix suspense (#777)

* fix #494

* add comment

* rename to initialMountedRef

* 0.3.9

* fix: mark isValidating as false when key is falsy (#757)

* fix: tear down when key turns to empty

* use false for empty key

* Fix README.md typo (#783)

'/api/data' => '/api/user' in "Multiple Arguments"

* fix: do mount check in config callback (#787)

* Update api-hooks example README.md (#790)

Updated the Vercel deploy link to the correct directory

* Return '@null' if args is null ASAP (#767)

* chore: return 'null' if arg[i] is null ASAP

* chore: update comment

* chore: use continue

* Bump ini from 1.3.5 to 1.3.8 (#806)

Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](npm/ini@v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update test

Co-authored-by: Shu Ding <[email protected]>
Co-authored-by: X <[email protected]>
Co-authored-by: Umidbek Karimov <[email protected]>
Co-authored-by: Paco <[email protected]>
Co-authored-by: matamatanot <[email protected]>
Co-authored-by: Jiachi Liu <[email protected]>
Co-authored-by: sAy <[email protected]>
Co-authored-by: William Crutchfield <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants