0

I'm trying to use redux-router in a project, but I cannot get it to work.

Here is my routes definition (partial) :

export default function(store) {
  return (
    <Route path="/" component={Main}>
      [ALL NESTED ROUTES]
    </Route>
  )
}

My routes work well with react-router.

And then my init code (partial) :

import ReduxRouter from 'redux-router'
import {Provider} from 'react-redux' 
[...]

const routes = Routes(store);

class Root extends Component {
    render() {
        return (
            <div>
                <Provider store={store}>
                    <ReduxRouter>{routes}</ReduxRouter>
                </Provider>
            </div>
        );
    }
}

ReactDOM.render(<Root />, document.getElementById('content'));

I get the following error on the ReduxRouter's createElement :

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).

I get the following error if I just try to write to console :

<ReduxRouter>{routes}</ReduxRouter>

In the console, I get a Symbol(react.element) with correct props (my routes as children), but with type undefined

As a consequence, I then get :

Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of Root.

What am I missing ?

1 Answer 1

0

OK, that was a stupid one. I was just importing ReduxRouter incorrectly.

Correct import is :

import { ReduxRouter } from 'redux-router'

Thanks to @tomo from Reactiflux for pointing that out !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.