FlowRouter + React

When using FlowRouter with React, do you need to use react-layout or react-mounter?

Theres quite a bit of conflicting info on which is suppose to be used and different tutorials are using different things. Which is it?

You don’t need to. But you can if you feel it makes your life easier. In our internal apps we use FlowRouter with React, but without react-layout etc.

React-mounter was made to remove the dependency on the React meteor package (no longer an issue)

Since things are heading towards npm, use react-mounter

You don’t really need it either. You can just call React.render directly from the route.

2 Likes

Mind Blown

1 Like

React Mounter. Flow router is used with react mounter,

So what would that look like?

With react-mounter, apparently you do something like:

mount(MainLayout, {
  content: <MyComponent />
});

and place {content} where you’d like it to render.

How do you do that with just React.render()?

You can do something like:

ReactDOM.render((
  <Layout>
    <MyComponent />
  </Layout>
), document.getElementById('app'));

And Layout can just be:

<div>
  {this.props.children}
</div>
3 Likes