Nozbe / withObservables

HOC (Higher-Order Component) for connecting RxJS Observables to React Components
https://github.com/Nozbe/WatermelonDB
MIT License
68 stars 26 forks source link

getObservables called whether triggerProps null or not matching. #107

Closed dungnguyen10989 closed 3 years ago

dungnguyen10989 commented 3 years ago

I connected my Component, I only triggered a route (react-navigation props) change, but when I dispatch an action to add a record to the POST table then getObservables still calls to generate a new props to my Component ?

export default withDatabase(
  withObservables(['route'], (props: Props) => ({
    data: props.database.collections
      .get<DtoPost>(TABLES.POST)
      .query()
      .observe(),
  }))(ListPost),
);
radex commented 3 years ago

I'm pretty sure that route is an object that's regenerated on every change to navigation. A change in identity will cause a re-render, which is standard behavior in React