Skip to content

connected components not updating on prop change #120

@lwakefield

Description

@lwakefield

I set up an example here in this example, I would expect that "I am thing: " is kept in sync with "count: ".

Given a connected component:

@connect((state, props) => ({ thing: state.things[props.id] }))
class Thing extends Component {
  render() {
    return <div children={"I am thing: " + this.props.thing} />;
  }
}

I would expect that you could update <Thing /> by passing in a new props.id - however the connected component is set up to only update the internal state when there is a change in the unistore - store instance: https://github.com/developit/unistore/blob/master/src/integrations/preact.js#L37.

Is it considered poor design to use connect to fetch state based on passed props?

Here is a proposed solution: master...lwakefield:master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions