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

Transition group import problem #131

Open
jondlm opened this issue Mar 21, 2016 · 6 comments
Open

Transition group import problem #131

jondlm opened this issue Mar 21, 2016 · 6 comments
Labels

Comments

@jondlm
Copy link
Contributor

jondlm commented Mar 21, 2016

We recently encountered a strange bug where one of our users with webpack ran into the dreaded Only a ReactOwner can have refs error when importing the Banner component. After further investigation, we found that the problem was with react-addons-css-transition-group and the way it imports react.

Turns out that react-addons-css-transition-group is simply a pointer back to the react repo. For some reason during transpilation (or something) it's turning that into require('./React') which webpack considers a different modules than regular react. Ultimately this can lead to multiple copies of react being imported in our client libraries.

We found a temporary fix which was to add the following line to the externals section of the webpack config:

externals: {
  'react': 'React',
  'react-dom': 'ReactDOM'

  // to avoid duplicate import of React with react-addons-css-transition-group
  './React': 'React',
  './ReactDOM': 'ReactDOM'
},

I'm not sure how to fix this. I wonder if part of the problem is that we're requiring transition groups as a regular dependency instead of a peer dep.

@jondlm jondlm added the bug label Mar 21, 2016
@tarun
Copy link
Contributor

tarun commented Mar 24, 2016

Just noticed this happens with ReactDOM too inside ReactCSSTransitionGroupChild
I believe it is triggered by Dialog
My fixed externals block no looks like..

externals: {
    'bluebird': 'Promise',

    'react': 'React',
    'react-dom': 'ReactDOM',

    // to avoid duplicate import of React with react-addons-css-transition-group
    './React': 'React',
    './ReactDOM': 'ReactDOM'
}

@jhsu
Copy link
Collaborator

jhsu commented Mar 31, 2016

This is because react is being used as an external.

if you want to use it as an external, you need to include react with addons and and map react-addons-css-transition-group to React.addons.CSSTransitionGroup.

see: facebook/react#6343

@strunkandwhite
Copy link
Contributor

@jondlm
Copy link
Contributor Author

jondlm commented Apr 25, 2016

We might be able to do away with transition group in favor of react-motion that is coming with the graphs work.

@jondlm
Copy link
Contributor Author

jondlm commented Jan 31, 2017

Leaving this ticket around because we want to move away from css transition group

@alisonailea
Copy link
Contributor

alisonailea commented May 2, 2017

React.addons.CSSTransitionGroup has been depreciated in favor of https://github.com/reactjs/react-transition-group which is now being actively maintained and solves many of these problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants