MCPcopy Create free account
hub / github.com/FormidableLabs/react-live / evalCode

Function evalCode

packages/react-live/src/utils/transpile/evalCode.ts:3–10  ·  view source on GitHub ↗
(
  code: string,
  scope: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

1import type { ComponentType } from "react";
2
3const evalCode = (
4 code: string,
5 scope: Record<string, unknown>,
6): ComponentType => {
7 const scopeKeys = Object.keys(scope);
8 const scopeValues = scopeKeys.map((key) => scope[key]);
9 return new Function(...scopeKeys, code)(...scopeValues);
10};
11
12export default evalCode;

Callers 2

generateElementFunction · 0.85
renderElementAsyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected