Search code examples
react-routermartyjs

marty.js ApplicationContainer and Rect Router 1.0.0 beta


I'm attempting to use Marty v0.10 and React Router v1.0.0. The example React Router provides doesn't seem to allow wrapping a handler in the application container. React Router says to use React.render as opposed to Router.run. The only example of Router.run is on the server side.

My implementation from marty.js v0.10 and React Router v0.13 throws the following error:

Invariant Violation: Router.run needs a callback

This is due to Router.run now expecting 3 parameters. I'm not sure what the second parameter should be in the browser.

Any tips on getting this:

Router.run(routes, (Handler, state) => {
  React.render(
    <ApplicationContainer app={ application }>
      <Handler { ...state.params } />
    </ApplicationContainer>,
    document.body
  );
});

to work with Rect Router 1.0.0 beta?


Solution

  • Obvious question is obvious.

    Just throw the render logic into React.render.

    React.render(
      <ApplicationContainer app={ application }>
        { routes }
      </ApplicationContainer>
      , document.body
    );