I have react app I created using create-react-app. I am tying to take user code and evaluate it to render it.
Here is what I have tried so far.
import React, { Component } from 'react';
import './App.css';
import { transform } from "@babel/standalone";
const code = transform("<span>Hello world</span>", {
presets: ["@babel/react", "@babel/env"],
}).code
class App extends Component {
render() {
return (
<div className="App">
<div>
{eval(code)}
</div>
</div>
);
}
}
This code gives me the following error in my terminal.
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
I am on a mac if that matters.