preactjs / preact-router

:earth_americas: URL router for Preact.
http://npm.im/preact-router
MIT License
1.01k stars 155 forks source link

render() not triggered when component is connected with preact-redux #320

Open untitledlt opened 5 years ago

untitledlt commented 5 years ago

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>
        );
    }
}
developit commented 4 years ago

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.

untitledlt commented 4 years ago

I have migrated to preactx and react-redux. The issue is gone.