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

Invariant Violation #1

Closed
evandavis opened this issue Jul 7, 2016 · 4 comments
Closed

Invariant Violation #1

evandavis opened this issue Jul 7, 2016 · 4 comments

Comments

@evandavis
Copy link
Contributor

evandavis commented Jul 7, 2016

This example throws an invariant violation as well as Warning: React.createElement: type should not be null, undefined, boolean, or number. What am I missing?

import React from 'react';
import I18n, {i18nState} from 'redux-i18n';
import {Provider} from 'react-redux';
import {render} from 'react-dom';

import {combineReducers, createStore, applyMiddleware} from 'redux';
import thunkMiddleware from 'redux-thunk';

const translations = {
  en: {
    'account.messaging.hub.title': 'Messages'
  }
};

const middleware = applyMiddleware(thunkMiddleware);
const store = createStore(combineReducers({i18nState}), {}, middleware);

render(
  <Provider store={store}>
    <I18n translations={translations}>
      <div>Hello World!</div>
    </I18n>
  </Provider>,
  document.getElementById('pageContainer-content')
);

Package versions:

react@15.2.0
react-dom@15.2.0
redux@3.5.2
react-redux@4.4.5
redux-i18n@1.0.2
@francescarpi
Copy link
Member

Hi evandavis,

I can't reproduce your bug. What React version do you have?. Can you show me your store configuration, please?

And finally, are you sure that pageContainer-content exists in your main template?

Best regards.

@evandavis
Copy link
Contributor Author

@francescarpi I've updated my example to provide a minimum viable demonstration with all the configuration inlined as well as my package versions.

I am certain that pageContainer-content exists.

@evandavis
Copy link
Contributor Author

evandavis commented Jul 8, 2016

Update: if I copy the source directly into my app and reference import I18n from './i18n/component'; I get the intended result. Perhaps there is a problem in the distribution?

Found the issue; opened a PR.

@francescarpi
Copy link
Member

Hi evendavis!

Now I have seen that the documentation is wrong because the correct way for package import is:

javascript import {I18n} from 'redux-i18n'

not,

javascript import i18n from 'redux-i18n'

But I like your proposal. Today or tomorrow I'll create a new tag.

Thanks!

francescarpi pushed a commit that referenced this issue Jul 14, 2017
add hoc to abstract away context
francescarpi pushed a commit that referenced this issue Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants