I have this API route like this
app.get('/', function(req, res) {
res.send('hello world');
});
what i want is when the user goes to that route. I want it to render a react component. But when i call that component like this
const {VideoChat} = require("../src/VideoChat");
app.get('/', function(req, res) {
res.send('VideoChat');
});
it gives me an error that says
import React, { useState, useCallback } from 'react'; ^^^^^^ SyntaxError: Cannot use import statement outside a module
Component looks like this :- `videoChat.js
const VideoChat = () => {
let render;
if (token) {
render = (
<Room roomName={roomName} token={token} handleLogout={handleLogout} />
);
} else {
render = (
<Lobby
username={username}
roomName={roomName}
handleUsernameChange={handleUsernameChange}
handleRoomNameChange={handleRoomNameChange}
handleSubmit={handleSubmit}
/>
);
}
return render;
};
export default VideoChat;