meteor / react-packages

Meteor packages for a great React developer experience
http://guide.meteor.com/react.html
Other
573 stars 158 forks source link

Broken example in Routing section of React in Meteor guide #140

Closed rikonor closed 3 years ago

rikonor commented 8 years ago

Hi,

This example from Routing breaks when refreshing the page.

FlowRouter.route('/blog/:postId', {
  action(params) {
    const containerElement = document.getElementById("app-container");
    ReactDOM.render(<AppBody postId={params.postId} />, containerElement);
  }
});

The problem is that when ReactDOM.render is called, the document is not ready, resulting in an error.

Haven't looked into how, but ReactLayout fixes this so I suggest replacing the example with a working one utilizing ReactLayout.

Notice that the basic usage of ReactLayout doesn't even require an actual "layout" per se, so the render line in the previous example could just be replaced with

ReactLayout.render(AppBody { postId: params.postId });

whereas if more complex layouts are desired the user can refer to the ReactLayout docs as the guide currently suggests.

thomasmery commented 8 years ago

Hi,

just stumbled upon the same thing - thanks for the heads up

also tried to wrap the FlowRouter init in Meteor.startup but of course the router needs to kick in before that (There is no route for the path: /)

+1 for updating the docs

nice article here : https://themeteorchef.com/snippets/using-flow-router-with-react/

filipenevola commented 3 years ago

I'm closing this just because it's too old. We can open new issues for items that are still valid.