arunoda / react-komposer

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

Way to show loading component again #118

Closed RafaelVidaurre closed 8 years ago

RafaelVidaurre commented 8 years ago

After onData is called with data, the loading componen is (of course) not rendered anymore.

Is there a way to force that component to show again? I'm building a component which specifically requires to show the loading... component again after props change.

RafaelVidaurre commented 8 years ago

Well, apparently passing null as onData's second argument causes the loading... component to show again

thomasKn commented 7 years ago

Same problem here, I want to show the loading component again:

const onPropsChange = (props, onData) => {
  Meteor.call('ordersByDateRange', props.minDate, props.maxDate, props.value, function (error, result) {
    const data = result;
    onData(null, { data });
  });
};

export default composeWithTracker(onPropsChange)(GetOrders);

I tried to pass null as onData's second argument but no success:

const onPropsChange = (props, onData) => {
  Meteor.call('ordersByDateRange', props.minDate, props.maxDate, props.value, function (error, result) {
    const data = result;
    onData({ data }, null);
  });
};

Any idea?

Dartv commented 7 years ago

I'm not sure but have you tried like this?

const onPropsChange = (props, onData) => {
  onData();
  Meteor.call('ordersByDateRange', props.minDate, props.maxDate, props.value, function (error, result) {
    const data = result;
    onData(null { data });
  });
};
thomasKn commented 7 years ago

Many thanks @RevelsGit ! It works like a charm ;)