Skip to content

Instantly share code, notes, and snippets.

@jonsherrard
Created February 20, 2017 15:43
Show Gist options
  • Save jonsherrard/07869a306846bf65d325d046a346d753 to your computer and use it in GitHub Desktop.
Save jonsherrard/07869a306846bf65d325d046a346d753 to your computer and use it in GitHub Desktop.
class Post extends Component {
static loadProps(routeParams) { // from WordPress API
return [
`posts?filter[slug]=${routeParams.post.slug}`,
`menus?filter[name]=main`,
`options`
]
}
}
// react router matches on a request
let permalink = route.path // `/cheese/blue/i-love-stilton`
let resource = getProps ? : getProps() || defaultResources(route.path) : null
{ fetchPost } from './actions'
const renderData = fetchPost(permalink, resource)
reduxStore = {
resources: [
'/cheese/blue/i-love-stilton': PostObject
]
}
reduxStore[permalink] || fetch(permalink).then(data => reduxStore[permalink] = data.toJson)
render(<App reduxStore={reduxStore/>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment