nicolaslopezj / react-meteor-data

Fetch Meteor data in React using decorators
38 stars 3 forks source link

withMethodData props are one state behind.. #3

Closed Twinski closed 8 years ago

Twinski commented 8 years ago
@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

nicolaslopezj commented 8 years ago

Merged