Open ukntpm opened 3 years ago
Currently, there is missing undefined check in React.useState(). Check here : https://github.com/uber/react-view/blob/fed53e07aede745e24f00ae4fc20e80f2ad7fc39/src/ast.ts#L228-L231 Since we are not passing any argument in React.useState(), it's not rendering appropriate content.
React.useState()
const [initialCode, setInitialCode] = React.useState(""); const {compilerProps, errorProps, editorProps} = useView({ initialCode }); React.useEffect(() => { setInitialCode(`() => { const [content, setContent] = React.useState(); // not passing any argument const text: string = "Hey"; return <h2>{text}</h2>; }`) });
Problem
Currently, there is missing undefined check in
React.useState()
. Check here : https://github.com/uber/react-view/blob/fed53e07aede745e24f00ae4fc20e80f2ad7fc39/src/ast.ts#L228-L231 Since we are not passing any argument inReact.useState()
, it's not rendering appropriate content.Example Code