wmr icon indicating copy to clipboard operation
wmr copied to clipboard

Infinite re-rendering if ErrorBoundary is direct child of LocationProvider

Open ghost opened this issue 4 years ago • 1 comments

This component tree is crashing my page when I navigate between routes:

<LocationProvider>
    <ErrorBoundary>
        <div>
            <Router>
                <Home path='/' default />
                <About path='/about' />
            </Router>
        </div>
    </ErrorBoundary>
</LocationProvider>

Putting a div as the direct child of LocationProvider fixes it:

<LocationProvider>
    <div>
        <ErrorBoundary>
            <Router>
                <Home path='/' default />
                <About path='/about' />
            </Router>
        </ErrorBoundary>
    </div>
</LocationProvider>

It doesn't have to be a dom element, this also fixes it:

<LocationProvider>
    <SWRConfig value={SWRConfiguration}>
        <ErrorBoundary>
            <Router>
                <Home path='/' default />
                <About path='/about' />
            </Router>
        </ErrorBoundary>
    </SWRConfig>
</LocationProvider>

If there's any additional information needed please let me know.

ghost avatar Dec 21 '20 06:12 ghost

Possibly related to https://github.com/preactjs/preact/issues/2747#issuecomment-699874181

developit avatar Dec 21 '20 17:12 developit