arunoda / react-komposer

Feed data into React components by composing containers.
MIT License
732 stars 70 forks source link

shouldSubscribe only works when propsToWatch is provided #158

Open vladbalan opened 7 years ago

vladbalan commented 7 years ago

It appears that shouldSubscribe only works as intended when propsToWatch is also provided in the options object, otherwise both currentProps and nextProps are equal to empty objects.

const options = {
  // propsToWatch: ['prop1', 'prop2', 'lastProp'],
  shouldSubscribe(currentProps, nextProps) {
    console.log('nextProps', nextProps); // returns {}
    console.log('currentProps', currentProps); // returns {}
  },
};

If propsToWatch is not provided, it defaults to null (https://github.com/arunoda/react-komposer/blob/a51a44de268587c1019ae834a95e24835fe23d85/src/compose.js#L14) and pick(props, null) === {} (https://github.com/arunoda/react-komposer/blob/a51a44de268587c1019ae834a95e24835fe23d85/src/compose.js#L59).