Invariant Violation running example
I ran the following commands to set up the example:
npm install
npm install react
npm install react-dom
npm run build
npm run build:example
cd example
node server
And when I open up localhost:3000 I see this error:
localhost/:45 Uncaught Invariant Violation: 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).
This should be resolved now after the investigation for #175 and #173
@securingsincity This is not resolved, still an issue.
This problem is related to "You are trying to add a ref to an element that is being created outside of a component's render() function."
https://facebook.github.io/react/warnings/refs-must-have-owner.html
This can be replicated if you create a component that contains the ace editor outside of your main react app and then import it through npm. This can be done in dev via npm linking. This may cause problems for any other open source components that incorporate ace editor.
Thanks @NickyYo I'll take a look tonight.
@NickyYo Sounds like you have an issue with multiple reacts. If you're making a reusable component that includes react-ace, make sure react/react-dom are in devDependencies and peerDependencies, not dependencies (http://stackoverflow.com/questions/30451556/what-is-the-correct-way-of-adding-a-dependency-to-react-in-your-package-json-for).
This gets funky when you use npm link because that doesn't install in the same way; it's just a symlink to the linked dependency, which means it'll pull in all of the installed dependencies, including the manually install react/react-dom. If you use a bundler like webpack, you can alias all import of react by putting this in the resolve section:
alias: {
'react': path.resolve(path.join(__dirname, 'node_modules', 'react')),
'react-dom': path.resolve(path.join(__dirname, 'node_modules', 'react-dom'))
}
This forces all component to use the base project's react modules.
@drewen Thanks Andrew! i'l be sure to do that! you're right i'm not doing it as dev dependencies
Thanks @drewen !