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

Is it possible to write Typescript in the playroom? #244

Open
jgodi opened this issue Sep 15, 2021 · 1 comment
Open

Is it possible to write Typescript in the playroom? #244

jgodi opened this issue Sep 15, 2021 · 1 comment

Comments

@jgodi
Copy link

jgodi commented Sep 15, 2021

I was wondering if there is a way to allow our users to write examples with Typescript inside of Playroom?

We have this component that we export to our users for some more complex examples:

export const FunctionWrapper = ({ children }) => children();

Then, it is used via and works for the majority of our use cases.

<FunctionWrapper>
  {() => {
    const [state, setState] = React.useState(123);
    return <div>{state}</div>;
  }}
</FunctionWrapper>

We have some spots where we want to show the proper Typescript approach for our more complex examples, but we can't get it to work. Any suggestions?

Something like this:

<FunctionWrapper>
  {() => {
    const [state, setState] = React.useState<number>123;

    const onClick = (event: MouseEvent) => {
      console.log("click");
    };

    return <div>{state}</div>;
  }}
</FunctionWrapper>
@iamtekeste
Copy link

hope you find an answer to your question, but wanted to say thank you for sharing that FunctionWrapper component, really handy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants