Closed jonathanglasmeyer closed 8 years ago
See the PR for a fix for my specific, minimal setup scenario. My current setup is:
const componentContext = /* some global state that should present on every route component */
const routes = <Route path='/' component={AppController} />;
const createElement = (Component, props) => {
const propsWithContext = {
...props,
context: componentContext,
};
return <Component {...propsWithContext} />;
};
const routerProps = {
createElement,
routes,
addressBar: true,
};
const router = <Router {...routerProps} />;
render(router, appName);
You are right. I'll take a closer look and get back to you on #11 soon.
I also want to start writing unit and integration tests so it'll hopefully make refactoring a little less painful going forward. I guess better late than never, 🤕, and as usual I'd have to remind myself the following quote to not feel too terrible about it.
If you are not embarrassed by the first version of your product, you’ve launched too late.
🍺
Awesome idea. :) That quote is on the wall of our office as well. 😄
I assume this issue is related to the following error I was getting:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `RouteView`.
because it went away when I updated the version of react-router-native
from ^2.0.0-alpha.0
(current version in NPM) to jmurzy/react-router-native#a9e4e01
(current master
in GitHub).
I want to supply
createElement
to the<Router>
to merge in props as documented here undercreateElement
. The behaviour is not as intended:RouteUtils::createNavigationTree
callscreateElement
withRouteView
, which passes the additional props to the RouteView component. This component in turn does not pass these additional props to theNavigationComponent
it creates. I'm not totally sure how to implement this which is why i created an issue first. I would assume thatcreateElement
should be called onNavigationComponent
, not onRouteView
. What do you think?