Search code examples
javascriptreactjswebpackreact-componentvideo-reactjs

Video React Component showing error


I'm using the react-video-player component in my project & while using it in the page, it's showing me the following error. I have attached the screenshot.

enter image description here

Can anyone help ? I'm having the following code:

import React, { Component } from "react";
import "video-react/dist/video-react.css";
import { Player } from 'video-react';

class VideoPlayer extends Component {
  render() {
    return(
      <Player
          playsInline
          poster="/assets/poster.png"
          src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4"
      />
    );
  }
}
export default VideoPlayer;

and also I'm having the following config file which might help you understand the error.

/* webpack.config.js */

/* eslint comma-dangle: ["error",
 {"functions": "never", "arrays": "only-multiline", "objects":
 "only-multiline"} ] */

const webpack = require('webpack');
const pathLib = require('path');

const devBuild = process.env.NODE_ENV !== 'production';

const config = {
  entry: [
    'es5-shim/es5-shim',
    'es5-shim/es5-sham',
    'babel-polyfill',
    './app/bundles/HelloWorld/startup/registration',
  ],

  output: {
    filename: 'webpack-bundle.js',
    path: pathLib.resolve(__dirname, '../app/assets/webpack'),
  },

  resolve: {
    extensions: ['.js', '.jsx'],
  },
  plugins: [
    new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
  ],
  module: {
    rules: [
      {
        test: require.resolve('react'),
        use: {
          loader: 'imports-loader',
          options: {
            shim: 'es5-shim/es5-shim',
            sham: 'es5-shim/es5-sham',
          }
        },
      },
      {
        test: /\.jsx?$/,
        use: 'babel-loader',
        exclude: /node_modules/,
      },
    ],
  },
};

module.exports = config;

if (devBuild) {
  console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
  module.exports.devtool = 'eval-source-map';
} else {
  console.log('Webpack production build for Rails'); // eslint-disable-line no-console
}

Solution

  • You may need css loader in webpack

    {
          test: /\.css$/,  
          include: /node_modules/,  
          loaders: ['style-loader', 'css-loader'],
     }