nicolaslopezj/react-meteor-data

withMethodData props are one state behind..

Closed this issue · 1 comments

@withData((props) => {
        console.log('Current page', reactive_current_page.get())
    return {
        current_page: reactive_current_page.get(),
        onNextPageClick: () => { reactive_current_page.set(reactive_current_page.get()+1) },
        onPrevPageClick: () => { reactive_current_page.set(reactive_current_page.get()-1) }
    }
})
@withMethodData((props, callback) => {
    console.log('withMethodData', 'Current page', props.current_page)
})
class OffersPage extends React.Component {
    ....
}

In the withMethodData console log, the props is always one state behind..
So in withData, this is the log: "Current page 1"
in withMethodData, this is the log: "Current page 1'"

If I execute onNextPageClick, withData logs: "Current page 2"
BUT withMethodData logs "'Current page 1"..

Is that normal behavior?
I submitted a pull request. Could you have a look?
#2

Merged