preact-router
preact-router copied to clipboard
render() not triggered when component is connected with preact-redux
I tried a minimal install with latest preact-cli.
Right after component is connected with preact-redux, navigating to route with query params stops triggering rerender.
F.e. navigating to /profile or / works fine but that's not the case with /profile/john.
It works if i refresh page or after something (redux?) triggers props change.
handleRoute function attached to <Router/> works fine.
With older versions (not sure preact or preact-router) everything works fine.
import { h, Component } from 'preact';
import { Link } from 'preact-router/match';
import { connect } from 'preact-redux';
@connect(state => state, { })
export default class Profile extends Component {
render({ user }) {
return (
<div>
<h1>Profile: {user}</h1>
<Link href="/">Home</Link> {/* this works fine */}
<Link href="/profile">Me</Link>
<Link href="/profile/john">John</Link>
<Link href="/profile/foo">foo</Link>
<Link href="/profile/bar">bar</Link>
</div>
);
}
}
I looked into this and added a reproduction to the preact-redux issue. It's not likely to be related to preact-router, but rather that rendering a connected component with new props does not reevaluate its redux bindings.
I have migrated to preactx and react-redux. The issue is gone.