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

Allow variables inside the function body #39

Open
anishagg17 opened this issue Jun 10, 2020 · 5 comments
Open

Allow variables inside the function body #39

anishagg17 opened this issue Jun 10, 2020 · 5 comments
Labels
question Further information is requested

Comments

@anishagg17
Copy link

anishagg17 commented Jun 10, 2020

currently variables inside the function body are only made available when they are passed to the component itself and are mentioned stateful:true , no support for other type of variables is found

@tajo
Copy link
Contributor

tajo commented Jun 23, 2020

Not sure what you mean. Can you provide some examples? stateful: true is to create a state while using the hook.

@tajo tajo added the question Further information is requested label Jun 23, 2020
@anishagg17
Copy link
Author

()=>{

const on;  // talkingAboutThisVariable

return <Toggle title={on?"on":"off"}/>
}



@tajo
Copy link
Contributor

tajo commented Jun 23, 2020

Code like this works

export default () => {
  const label = 'ok';
  return (
    <button>{label}</button>
  );
}

@anishagg17
Copy link
Author

yes but how to get that const label = 'ok'; within the code body ?

@tajo
Copy link
Contributor

tajo commented Jun 23, 2020

Hm, not sure what exactly your use-case is. If you are using "live-code only" setup, you can pass it through initialCode: https://react-view.netlify.app/?path=/story/useview--live-code-only

If you are using knobs where the code auto-generated, there is no way to tell react-view "add this variable right here...".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants