I’m trying to use usePageLoadingContext
fallowing documentation instruction.
I get this error:
Im using RW 0.48.0 with yarn 3.
I’m trying to use usePageLoadingContext
fallowing documentation instruction.
I get this error:
Im using RW 0.48.0 with yarn 3.
Hi @bogdan2510
I can see that the error message comes from:
I haven’t actually used that before, so I had to look it up in the docs here:
And I tried it v0.49.1 as well and got
I’ll write up an issue – or perhaps the docs are incomplete.
Thanks for letting us know!
I believe I have a workaround for it in this comment here Error: usePageLoadingContext must be used within a PageLoadingContext provider · Issue #4705 · redwoodjs/redwood · GitHub
// web/src/pages/HomePage/HomePage.test.js
// Import the PageLoadingContext from the router
import { PageLoadingContext } from '@redwoodjs/router'
import { render } from '@redwoodjs/testing/web'
import HomePage from './HomePage'
describe('HomePage', () => {
it('renders successfully', () => {
expect(() => {
render(
// Wrap the component (a page in this case) in the PageLoadingContext.Provider
// with the desired value
<PageLoadingContext.Provider value={{ loading: true }}>
<HomePage />
</PageLoadingContext.Provider>
)
}).not.toThrow()
})
})