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

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

Open untitledlt opened this issue 6 years ago • 2 comments
trafficstars

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>
        );
    }
}

untitledlt avatar Jun 05 '19 22:06 untitledlt

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.

developit avatar Sep 16 '19 18:09 developit

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

untitledlt avatar Sep 17 '19 06:09 untitledlt