Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Uncaught Error: addComponentAsRefTo(...): Only a ReactOwner can have refs. #24

Closed
berthelol opened this issue Oct 12, 2017 · 5 comments · Fixed by #26
Closed

Uncaught Error: addComponentAsRefTo(...): Only a ReactOwner can have refs. #24

berthelol opened this issue Oct 12, 2017 · 5 comments · Fixed by #26

Comments

@berthelol
Copy link

berthelol commented Oct 12, 2017

I have this error when I try to use react-progressbar.js in my react App.
error

I figured it was because react was called inside react-progressbar.js
npm ls react

I don't know how to fix it. I tried using alias and putting react in externals but nothing worked...
Here is my webpack.

const webpack = require('webpack');
const path = require('path');
module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: path.join(__dirname, '/public/'),
    publicPath: '/',
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.ProvidePlugin({
      WaveSurfer: 'wavesurfer.js'
    })
  ],
  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['react', 'es2015', 'stage-1']
      }
    },
    {test: /\.(jpe?g|png|gif|svg)$/i,
        loaders: [
          'file?hash=sha512&digest=hex&name=[hash].[ext]',
          'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
        ]}
  ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx'],
    alias: {
      wavesurfer: require.resolve('wavesurfer.js')
    }
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './'
  }
};

And here is my package.json

{
  "name": "corleone",
  "version": "1.0.0",
  
  "main": "index.js",
  "repository": "[email protected]:analysR/corleone.git",
  "scripts": {
    "dev": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "build": "webpack --config ./webpack.config.js --progress",
    "start": "node ./server/index.js",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
    "test:watch": "npm run test -- --watch"
  },
  "author": "Loïc Berthelot & Pierre Jankowiez",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",
    "chai": "^3.5.0",
    "chai-jquery": "^2.0.0",
    "file-loader": "^0.11.2",
    "image-webpack-loader": "^3.4.2",
    "jquery": "^2.2.1",
    "jsdom": "^8.1.0",
    "mocha": "^2.4.5",
    "react-addons-test-utils": "^0.14.7",
    "webpack": "^1.12.9",
    "webpack-dev-server": "^1.14.0"
  },
  "dependencies": {
    "axios": "^0.16.2",
    "babel-preset-stage-1": "^6.1.18",
    "body-parser": "^1.18.2",
    "bv": "git+https://PierreJankoECE:[email protected]/analysR/bv.git",
    "chain": "git+https://PierreJankoECE:[email protected]/analysR/chain.git",
    "cookie-parser": "^1.4.3",
    "cors": "^2.8.4",
    "express": "^4.15.5",
    "firebase-key": "^1.0.5",
    "lodash": "^3.10.1",
    "morgan": "^1.9.0",
    "multer": "^1.3.0",
    "nconf": "^0.8.5",
    "nedb": "^1.8.0",
    "nocache": "^2.0.0",
    "react": "^0.14.3",
    "react-audio-player": "^0.6.2",
    "react-dom": "^0.14.3",
    "react-file-input": "^0.2.5",
    "react-loader": "^2.4.2",
    "react-notifications": "^1.4.3",
    "react-progressbar.js": "^0.2.0",
    "react-redux": "4.3.0",
    "react-router": "^2.0.1",
    "react-wavesurfer": "^0.8.6",
    "redux": "^3.0.4",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.2.0",
    "socket.io": "^2.0.3",
    "vantage": "^1.7.0",
    "vorpal": "^1.12.0",
    "wavesurfer.js": "^1.4.0"
  }
}

Thank you very much

@delafields
Copy link

+1

@berthelol
Copy link
Author

#26 didn't fix my issue ...

@medialwerk
Copy link

+1

@tedwong
Copy link

tedwong commented Nov 10, 2017

It should happen if u using React 16, with multiple React version installed.
I think the possible solution should be:

  1. Update the alias in webpack.config:
alias: {
  react: path.resolve('node_modules/react'),
  'react-dom': path.resolve('node_modules/react-dom')
},
  1. Update the code, replace the React.CreateClass > var createReactClass = require('create-react-class');

https://stackoverflow.com/questions/46482433/reactjs-createclass-is-not-a-function

@Bazeloth
Copy link

Will be fixed as soon as this PR gets through:

#26

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

Successfully merging a pull request may close this issue.

5 participants