Open vladbalan opened 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.
shouldSubscribe
propsToWatch
currentProps
nextProps
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).
null
pick(props, null) === {}
It appears that
shouldSubscribe
only works as intended whenpropsToWatch
is also provided in the options object, otherwise bothcurrentProps
andnextProps
are equal to empty objects.If
propsToWatch
is not provided, it defaults tonull
(https://github.com/arunoda/react-komposer/blob/a51a44de268587c1019ae834a95e24835fe23d85/src/compose.js#L14) andpick(props, null) === {}
(https://github.com/arunoda/react-komposer/blob/a51a44de268587c1019ae834a95e24835fe23d85/src/compose.js#L59).