ryanflorence / async-props

Co-located data loading for React Router
MIT License
563 stars 48 forks source link

Promise support #65

Open kinday opened 8 years ago

kinday commented 8 years ago

Hey, I’d like to use async-props in my current project, but it lacks Promise support. How about mixing new and old school, huh?

If you like the idea, I’m willing to implement this feature myself.

nelix commented 8 years ago
static loadProps(params, cb) {
    Promise.resolve({ilike: 'turtles'}).then(cb);
}
Wildhoney commented 7 years ago

@kinday please do – I'd much rather Promise support than the old-fashioned callback approach. We could then go a step further with allowing static async function:

static async loadProps(params) {

    const user = await getUser(params.user);
    const photos = await getPhotos(user);

    return { user, photos };

}