Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOC components don't work on <Route render=HOC /> or <route component=HOC />? #5190

Closed
heldrida opened this issue May 31, 2017 · 1 comment
Closed

Comments

@heldrida
Copy link

heldrida commented May 31, 2017

Version

4.0.0

Test Case

https://codepen.io/helderoliveira/pen/rmXdgd

Steps to reproduce

Pass a function that returns a component to component={} or render={}
You can also find it reported here ( https://stackoverflow.com/questions/44289973/react-router-4-nesting-routes-alternative-technique )

Expected Behavior

If not support to return an error message

Actual Behavior

Blank

Also tried,


import React from 'react'
import { Route } from 'react-router'
import { BrowserRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import App from '../app/containers/app'
import rootRoutes from './routes'

const Root = ({store, history}) => {
  return (
    <Provider store={store}>
      <BrowserRouter history={history}>
        <Route exact path='/' render={routeProps => <App {...Object.assign({}, routeProps, ...rootRoutes[0].routes)} />} />
      </BrowserRouter>
    </Provider>
  )
}

export default Root
@heldrida heldrida changed the title HOC components don't work on <Route render=X /> or <route component=X />? HOC components don't work on <Route render=HOC /> or <route component=HOC />? May 31, 2017
@heldrida
Copy link
Author

Forget it, I was doing it wrong. Solution for future readers:


import React from 'react'
import { Route } from 'react-router'
import { BrowserRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import App from '../app/containers/app'
import rootRoutes from './routes'

const Root = ({store, history}) => {
  return (
    <Provider store={store}>
      <BrowserRouter history={history}>
        <Route path='/' render={routeProps => <App {...Object.assign({}, routeProps, { routes: rootRoutes[0].routes })} />} />
      </BrowserRouter>
    </Provider>
  )
}

export default Root

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant