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

Element ref was specified as a string (trigger) but no owner was set. #19

Closed
jvgomg opened this issue Nov 3, 2017 · 3 comments
Closed

Comments

@jvgomg
Copy link
Contributor

jvgomg commented Nov 3, 2017

I am trying to use this component in my app but getting the following error:

Element ref was specified as a string (trigger) but no owner was set. You may have multiple copies of React loaded. (details: https://fb.me/react-refs-must-have-owner).

I cannot find the string "trigger" anywhere in the source code. Thanks for any help!

@mrchief
Copy link
Collaborator

mrchief commented Nov 3, 2017

This issue arises when you have multiple copies of react being loaded on the page. Its hard to pinpoint what is causing this without having more details but few common pitfalls are misconfigured webpack/npm dependencies.

E.g., misconfigured externals in webpack:

// bad:  
externals: {
  'react': 'react',
  'react-dom': 'ReactDOM'
}

// good 
externals: {
  'react': 'React',  // main entry point of React starts with capital R
  'react-dom': 'ReactDOM'
}

Another solution would be to delete mode_modules (destroy it completely, including any symlinks) and doing npm install again.

Make sure only one version of React is specified in your dependencies (including dev and peer dependencies).

@jvgomg
Copy link
Contributor Author

jvgomg commented Nov 3, 2017

@mrchief Thank you for your response - you helped fix the problem

Yes it was dependancy issue – I realise I am using React@16 but have a number dependancies that list React@15 in their dependancies. I managed to add a fixed alias to my Webpack configs.

config.resolve.alias.react = path.resolve(__dirname, 'node_modules', 'react')

Through my Googling I come across the recommendation that libraries should not list React in their dependancies but instead should use peerDependancies (devDependancies is fine). Should I create a pull request to do that?

@mrchief
Copy link
Collaborator

mrchief commented Nov 3, 2017

Should I create a pull request to do that?

Sure would love to have a PR on that!

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

No branches or pull requests

2 participants