Skip to content

How to pass URL params to static fetchData component method? #3

@si-harps

Description

@si-harps

I'm keen to understand best practices for passing url params from the express route handler to the component being rendered server side. Currently, it looks as though the only way the is achievable is by using custom express routes when required or a hacky url split inside the static component method.

eg.

GET http://www.myapp.com/posts/:id (req.params.id required to load post 10 from external endpoint)

import { getPost } from './actions/post'

...

static fetchData(store) {
    // param 10 required from request url
    return store.dispatch(getPost(:id))
}

Any thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions