Can't seem to loop through <Location>
components using .map
as I get the following error as it's being passed as a string:
Error: Invariant Violation: Route handler should be a component or a function but got: MainPage
Array in question and the component:
[{
'path': '/',
'handler': 'MainPage'
},{
'path': '/users/:userName',
'handler': 'UserPage'
}]
var App = React.createClass({
render: function() {
var createRoute = function(item) {
return <Location path={item.path} handler={item.handler} />
}
return (
<Locations path={this.props.path}>
{this.props.paths.map(createRoute)}
<NotFound handler={NotFoundPage} />
</Locations>
)
}
})
This will work, but you can't pass your handlers as strings, you need to set the handler to the actual component that handles the route. RRC has no way of knowing what that refers to.