Spaces:
Sleeping
Sleeping
File size: 507 Bytes
8f493bb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import React from "react";
import { Streamlit } from "streamlit-component-lib";
const ReactComponent = ({ code }) => {
const Component = React.useMemo(() => {
try {
return new Function("React", return ${code})(React);
} catch (error) {
console.error("Error creating component:", error);
return () => <div>Error creating component: {error.message}</div>;
}
}, [code]);
React.useEffect(() => {
Streamlit.setFrameHeight();
}, [Component]);
return <Component />;
};
export default ReactComponent;
</antArtifact> |