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

[Bug]: useBlocker in SSR with data-router #10042

Closed
denchiklut opened this issue Feb 3, 2023 · 1 comment · Fixed by #10046
Closed

[Bug]: useBlocker in SSR with data-router #10042

denchiklut opened this issue Feb 3, 2023 · 1 comment · Fixed by #10046
Labels

Comments

@denchiklut
Copy link

What version of React Router are you using?

6.8.0

Steps to Reproduce

import { unstable_useBlocker as useBlocker } from 'react-router'

const App = () => {
    const [block, setBlock] = useState(false)
    const blocker = useBlocker(block)

    return <...>
}

Expected Behavior

We cant call hooks conditionally. So we will invoke this hook in both browser and server environments

Actual Behavior

Getting an error:

Uncaught Error: You cannot use router.getBlocker() on the server because it is a stateless environment
    at updateDehydratedSuspenseComponent (react-dom.development.js:20657:17)
    at updateSuspenseComponent (react-dom.development.js:20357:16)
    at beginWork (react-dom.development.js:21619:14)
    at beginWork$1 (react-dom.development.js:27421:14)
    at performUnitOfWork (react-dom.development.js:26552:12)
    at workLoopSync (react-dom.development.js:26461:5)
    at renderRootSync (react-dom.development.js:26429:7)
    at performConcurrentWorkOnRoot (react-dom.development.js:25733:74)
    at workLoop (scheduler.development.js:266:34)
    at flushWork (scheduler.development.js:239:14)
@denchiklut denchiklut added the bug label Feb 3, 2023
@brophdawg11 brophdawg11 linked a pull request Feb 3, 2023 that will close this issue
@brophdawg11 brophdawg11 self-assigned this Feb 3, 2023
@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Feb 10, 2023
@brophdawg11 brophdawg11 removed their assignment Feb 10, 2023
@brophdawg11 brophdawg11 self-assigned this Feb 22, 2023
@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Feb 27, 2023
@brophdawg11 brophdawg11 removed their assignment Feb 27, 2023
@brophdawg11
Copy link
Contributor

This should be fixed in 6.8.2 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants