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

Support for incompatible React #8

Closed
lannn opened this issue Aug 9, 2016 · 9 comments
Closed

Support for incompatible React #8

lannn opened this issue Aug 9, 2016 · 9 comments

Comments

@lannn
Copy link

lannn commented Aug 9, 2016

Today, i add emoji-mart to my project. I get the conflict React with following message:

addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

What should i do to resolve this problem?
Thanks you so much!

@EtienneLem
Copy link
Member

Could I see a snippet of how you’re trying to use it?
What version of React are you using? I’ll try to reproduce.

@onekvinda
Copy link

I am getting the same error with React 15.3.0.

@EtienneLem
Copy link
Member

Any chance I can see how you’re importing/using the library? Thanks!

@onekvinda
Copy link

Basically I am just trying that in the empty component, so nothing fancy

import React, {Component, PropTypes} from 'react';
import {emojify} from 'react-emojione';
import {Picker} from 'emoji-mart'

export default class MessageEditor extends Component {
    render() {
        return (
            <div>
                <Picker sheetURL='https://npmcdn.com/emoji-mart@0.2.0/sheets/sheet_apple_64.png'/>
            </div>
        )
    }
}

I can try that in some clean project to rule out it's not for example issue with the node modules in my current project

@EtienneLem
Copy link
Member

It does look good.

There’s a chance that it’s because you have multiple versions of React installed locally.
Try npm ls | grep react, if you see more than one version that’s probably the issue.

You could either rm -rf node_modules and npm install or try only removing the extra React you don’t need.

@jeduan
Copy link

jeduan commented Sep 20, 2016

I had this same issue. I didn't have 2 reacts installed, however, It turned out that the culprit was that I had configured ProvidePlugin on webpack, like so:

plugins: [
  new webpack.ProvidePlugin({
      React: 'react'
  })
]

so it would see both React and react. The fix was loading Picker directly from src and make a special case in webpack's config to use emoji-mart's source.

import Picker from 'emoji-mart/src/components/picker';

on webpack.config:

loaders: [...,
  {
        test: /\.js$/,
        include: [
          path.join(__dirname, 'src'),
          path.join(__dirname, 'node_modules', 'emoji-mart')
        ],
        loader: 'babel-loader'
    },
]

@rachitGulati
Copy link

rachitGulati commented Sep 29, 2016

I am facing the same problem. Any update for this ?. I really liked this library and wanted to use it in my project.

I don't have duplicate react js version still I have tried rm -rf node_moduels and reinstalling it still no luck.

Just adding simple one line in my project

And it is showing the above error.

@EtienneLem
Copy link
Member

Do you also use webpack.ProvidePlugin?
I’ll try to reproduce.

@rachitGulati
Copy link

Thanks for fixing it now it's working superb.

No I was not using the ProvidePlugin.

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

5 participants