preact-router icon indicating copy to clipboard operation
preact-router copied to clipboard

[discuss, help] Understanding of <Match> behavior

Open k1r0s opened this issue 8 years ago • 2 comments
trafficstars

https://github.com/developit/preact-router/blob/83cf77acad33f9c8dd4a9104f23be90c9b8d381c/src/match.js#L9

Why do we setup subscribers after rendering the component?

But at the same time we expect eval children[0] and retrieve an expression. But maybe this expression needs to read subscribers to return the proper component to render...

k1r0s avatar Nov 02 '17 17:11 k1r0s

componentDidMount() only runs for client-side renders. componentWillMount() runs during SSR, which means setting up subscriptions there would trigger a memory leak (as they are never removed).

developit avatar Nov 15 '17 03:11 developit

But if this is the only problem wouldn't be the best approach to check by any means the current env:

if (ENV === 'SSR') .. whatsoever

right?

k1r0s avatar Nov 16 '17 09:11 k1r0s