-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
How to use playground as a React component? #273
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue. |
@SimonAlling tbh Playground intention was never the one you described. It's purpose was to ease testing and showcasing of the component. We had a similar request from community here #146 @magicmatatjahu you need to take it into account when you will work on probably removing the playground and replacing it with studio |
Thanks for the quick reply!
I thought so. Nevertheless, being able to use it that way would be an appreciated improvement.
Apparently I'm not the only one then. 🙂 |
yeap, we actually need it to for our new playground (studio) that we will work on I would suggest closing this issue and invite you to join the discussion here where among other things the future of the playground is also decided 😄 |
I see! Let the issue be closed then, but I'm not sure I have too much to add to the discussion in #265; I'm not that familiar with React. 😅 In the meantime, I managed to get it sort of working by copying the source code and fixing the type errors manually. The only problem is that if I go directly to the route where the playground is shown (i.e. I type I totally understand if there isn't enough context above to understand why this might be happening, but please let me know if you have any idea. |
@SimonAlling Hi! As @derberg wrote, the Playground intention was never to use as standalone editor/package, but as we see, more and more people want this feature. But also as Łukasz wrote, we are during the migration of the old playground (this is not the React playground 😄) to the new studio that will use the React component and finally we wanna also switch to studio with testing/developing playground for React component. Also Regarding to your problem with routing: tbh, I don't know 😅 I remember that once we had a similar problem in the playgroud (related to the transition between tabs for the playground to start working properly, but now everything working as expected - https://asyncapi.github.io/asyncapi-react/). I will write back to you, when I check what problem was. Also, if for you this is a real problem and priority, I mean using playground in app, if you could create a repository that I could download and test locally and check why it doesn't work for you, that would be great! |
Cool! 🙂 Indeed it is, so here you go. Thanks in advance! |
@SimonAlling Ok, I checked your repo. Sorry for delay, I saw your comment today 😅 So problem is not with our component or playground itself, but with in interface State {
...
afterFirstRender: boolean;
}
class Playground extends Component<{}, State> {
state = {
...
afterFirstRender: false,
};
componentDidMount() {
setTimeout(() => {
this.setState({ afterFirstRender: true, })
}, 100);
}
render() {
const { schema, config, schemaFromExternalResource, afterFirstRender } = this.state;
const parsedConfig = parse<ConfigInterface>(config || defaultConfig);
if (afterFirstRender === false) {
return null;
}
...
}
...
} So I wait 100msc after first render and then switch flag and everything works. I will also try another solution, but if you need only fast fix, here it is 😅 EDIT: TBH I don't know why we haven't this kind of problem in https://asyncapi.github.io/asyncapi-react/ |
Many thanks, @magicmatatjahu! I also experimented for a while but couldn’t figure out a better solution, so I’ll probably roll with it until the Studio is available. 🙂 |
@magicmatatjahu: Surprisingly, its not the actual delay per se that constitutes the workaround. This works just as well: componentDidMount() {
setTimeout(() => {
this.setState({ afterFirstRender: true, })
}, 0); // 👈
} However, this doesn't: componentDidMount() {
this.setState({ afterFirstRender: true, })
} So yeah … ¯\_(ツ)_/¯ |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
@magicmatatjahu I guess plan is to use |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Hey, please have a look at #146 (comment) |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Description
I'm building an app in which I would like to include the playground, i.e. the default-exported
Playground
component fromplayground/src/Playground.tsx
. However, it doesn't seem to be included in the npm package. I tried a very hacky solution usinggit submodule add https://github.com/asyncapi/asyncapi-react
and then, in my code,but after manually installing a dozen dependencies required by the playground, I still got a bunch of
TS6133
errors ('editor' is declared but its value is never read
etc) as well as aTS2322: Type 'Timeout' is not assignable to type 'number'
. And even if it had worked, it would have been a very hacky and fragile workaround.Reasons
It would be nice to be able to include the playground in a React app.
The text was updated successfully, but these errors were encountered: