Is it possible to use a React component from within an HTML file?

1946 views javascript

What I want to do is have a video with a set of controls below it. There are many places where I will need these controls, so I have decided to use React to render them so they are easily reusable.

Here is my code:

import React from 'react';
import ReactDOM from 'react-dom';
import './styles.css';

class VideoControls extends React.Component {
  render() {

  <VideoControls />,
/* code for tags */
html, body {
  height: 100%;

html {
  background-color: rgb(48, 48, 48);

body {
  padding: 16px;
  /* overrides default w3.css */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;

video {
  display: block;

/* specialised code for other elements */
.video-panel, .video-panel-second {
  background-color: rgb(75, 75, 75);
  color: rgb(185, 185, 185);
  height: 45%;
  width: calc(50% - 11px);
  display: inline-block;
  text-align: center;

.video-panel-second {
  margin-left: 16px;
<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="styles.css"/>
  <link rel="stylesheet" href="w3.css"/>
  <script src="" crossorigin></script>
  <script src="" crossorigin></script>
  <script src="" type="text/babel"></script>
  <title>Editor UI Demo</title>
  <div class="video-panel w3-container w3-padding-24 w3-round">
    <video id="source-video" src="/css-vse/assets/PostingLetter.MOV" height="100%" width="100%">Video not displayed.</video>
    <div id="controls"></div>
  <div class="video-panel-second w3-container w3-padding-24 w3-round">
    <video id="timeline-video" src="/css-vse/assets/Walking.MOV" height="100%" width="100%">Video not displayed.</video>
    <div id="controls"></div>  
  <script src="index.js"></script>

I want to render a <VideoControls> within div#controls but I keep getting an "Uncaught SyntaxError: Unexpected Identifier" when trying to do so. Is it possible to use the <VideoControls> React component from within my HTML file, or do I have to make the entire page a React app?

Thank you for your time.

answered question

1 Answer


Instead of using id to render the Component, use a class. Get the elements with the class name and in a loop render your react component.

Follow this answer I found on StackOverFlow, will help you sort this out.

posted this

Have an answer?


Please login first before posting an answer.