notthehoff
notthehoff

Reputation: 1242

How to route a dynamic page with Iron Router in Meteor?

Trying to set up a project using the format here. I have a file named view-scheduling.js set up in imports/pages/ folder. It contains:

export const ViewScheduling = () => (
    <div class="view-scheduling">
        This schedule
    </div>
)

The router looks like:

Router.route('/scheduling', {
    name: 'viewScheduling',
    onBeforeAction: function(){
        import '../imports/ui/pages/view-scheduling.js';
        this.next();
    }
})

I triple checked the path. I am getting the following error on load of http://localhost:3000/scheduling

Couldn't find a template named "ViewScheduling" or "viewScheduling". Are you sure you defined it?

How can I make 'this schedule' show up?

Upvotes: 0

Views: 289

Answers (1)

Michel Floyd
Michel Floyd

Reputation: 20246

iron-router expects blaze templates, not react. It's looking for the following html in an html file somewhere under /client:

<template name="ViewScheduling">
  <div class="view-scheduling">
    This schedule
  </div>
</template>

iron-router was the first router in the MeteorJS ecosystem back when MeteorJS used the blaze rendering system exclusively. Later the community moved to flow-router. More recently react-router-dom has also become popular.

Upvotes: 1

Related Questions