arunoda / react-komposer

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

shouldSubscribe not working #151

Open MaxTwentythree opened 7 years ago

MaxTwentythree commented 7 years ago

Hi,

the option shouldSubscribe does not seem to work.

When I have this ...

const options = {
    shouldSubscribe: (currentProps, nextProps) => {
        console.log(currentProps, nextProps);
        return false;
    }
};

compose(trackerLoader(myLoader), options)(MyComponent);

... the console.log is never triggered, nor does "return false" prevent the loader from reloading.

Am I doing something wrong or is this a bug?

MaxTwentythree commented 7 years ago

Same issue with 'propsToWatch' btw...

nkahnfr commented 7 years ago

Hi,

It's working fine for me.

Please note shouldSubscribe is never called on the first run since you need to subscribe to initialize the container. The function is called when one or more watched properties change for an "initialized" container. Hope it helps.