Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Undefined check in React.useState() #77

Open
ukntpm opened this issue Jul 30, 2021 · 0 comments
Open

Missing Undefined check in React.useState() #77

ukntpm opened this issue Jul 30, 2021 · 0 comments

Comments

@ukntpm
Copy link

ukntpm commented Jul 30, 2021

Problem

Currently, there is missing undefined check in React.useState().
Check here :

react-view/src/ast.ts

Lines 228 to 231 in fed53e0

if (
valueNode.type === 'StringLiteral' ||
valueNode.type === 'BooleanLiteral'
) {

Since we are not passing any argument in React.useState(), it's not rendering appropriate content.

Example Code

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>;
    }`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant