Compose-Web with React examples (#693)

* Add compose-web example with a react component
* Add example with a compose component in a react app

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
This commit is contained in:
Oleksandr Karpovich
2021-05-25 18:45:50 +02:00
committed by GitHub
parent 6cf9e5719f
commit a1d2f86609
15 changed files with 639 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
### Use Compose(web) in React app
[see ComposeInReactApp.kt](src/jsMain/kotlin/ComposeInReactApp.kt)
`useCompose(...)` is a custom React effect to render a content using Compose.
It's not a part of any library.
### Use React in Compose(web) app
`UseReactEffect(...)` is a custom Compose effect to render a content using React.
It's not a part of any library.
[see ReactInComposeApp.kt](src/jsMain/kotlin/ReactInComposeApp.kt)
### How to use existing React components:
It requires adding `external` declarations. For example: [ReactYoutubePlayer.kt](src/jsMain/kotlin/ReactYoutubePlayer.kt)
Here is a good tutorial - [Using packages from NPM](https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/07_Using_Packages_From_NPM)
### Running web application
```
./gradlew jsBrowserRun
```