Implement Dynamic Routes Using React Redux Starter Kit

I’m basically trying to implement this:

except with this starter kit:

The trouble that I’m running into is two fold.
1. I need to get data from the wordpress instance into my redux store as soon as I instantiate the store. I try to solve this problem by dispatching an asynchronous action right after I create my store in /store/createStore.js but it isn’t fast enough.

const store = createStore(
  store.dispatch( fetchEditorials() )
  console.log('lets see')

store.getState() is not displaying the updated data.

  1. I need to generate routes using the slugs I get from the wordpress array. Before I can generate routes I need to make sure that the wordpress data is inside the store, but also I don’t know where to write this code.

Either here:

export const createRoutes = (store) => ({
  path        : '/',
  component   : CoreLayout,
  indexRoute  : Home,
  childRoutes : [

or I created a new function:

function buildRoutes (store) {
  return store.getState(), i) => {
    return (
      <Route component='' key={} path={`/$posts.slug`} />

then I would pass this into childRoutes from the code above.

Read more here: Implement Dynamic Routes Using React Redux Starter Kit

Leave a Reply

Your email address will not be published. Required fields are marked *