https://kotlinlang.org logo
#compose-web
Title
# compose-web
m

Mini

01/21/2022, 6:12 PM
Does anyone have experience with creating compose-web wrappers for React components?
b

Big Chungus

01/21/2022, 6:27 PM
Why would you want to do that?? This would bloat your bundle size like crazy
This would be like wrapping angular components in react
m

Mini

01/21/2022, 6:28 PM
Organisation has an existing component library for the design system, implemented in React
https://github.com/JetBrains/compose-jb/blob/master/examples/web-with-react/src/jsMain/kotlin/ReactInComposeApp.kt Found this example, but Im wondering if anyone knows how painful it is to work with
b

Big Chungus

01/21/2022, 6:29 PM
Then you'd better use kotlin react wrappers
m

Mini

01/21/2022, 6:29 PM
But then I could’nt use compose?
b

Big Chungus

01/21/2022, 6:29 PM
Correct
m

Mini

01/21/2022, 6:29 PM
And I want to use compose
b

Big Chungus

01/21/2022, 6:30 PM
Then don't use react. All I'm saying is that wrapping react into compose just makes no sense as then you'd have to ship two runtimes in your js bundle which will be crazy
m

Mini

01/21/2022, 6:30 PM
Why is there a sample for it if its not feasible?
What makes you think I care about the bundle size? I might be building a kiosk application. At that point what does it matter?
b

Big Chungus

01/21/2022, 6:30 PM
Plus there will be countless of issues along the way to get those to sync up together. Just plain nightmare, best avoided.
The sample is there is just to show how compose can be integrated together with external systems. Probably following the Jetpack & CfD path of integrating with Swing and AndroidViews respectively.
But on the web, integrating with yet another framework would only make sense if you don;t target the browser with your app (which looks to be the case for you).
In that case go for it if you're really set on compose, just know that initial learning curve will be much higher than just using plain compose or plain react, because you'll need to understand some of the compose internals to integrate the two properly.
m

Mini

01/21/2022, 6:35 PM
Well Ive got quite some experience with compose, primarily working on Android. After that I really really dont want to go back to React. Hopefully soon TM we will have canvas based rendering for web, where we can use cross platform composables. I figured until then it would be easier to wrap our React component library than implementing them in compose-web from scratch, only to be replaced by the android Compose variants ASAP
b

Big Chungus

01/21/2022, 6:36 PM
Looks like best option would be to just wait for canvas 😄 But I appreciate you might have reasons why you can't wait.
❤️ 1
m

Mini

01/21/2022, 6:36 PM
Whats the latest news on canvas? Anything else than “at some point in the future”? 😅
b

Big Chungus

01/21/2022, 6:36 PM
One thing I could tell you from experience - HTML compose-web is quite different from Jetpack and CfD
Don't expect to "just pick it up" from day 1
Whats the latest news on canvas? Anything else than “at some point in the future”?
"At some point in closer future now" I guess 😄
I'm working on #kmdc components for compose-web if that helps at all, however it's still quite experimental.
h

hfhbd

01/21/2022, 7:11 PM
I don't have experience with React in combination with Compose, but did you already use Kotlin in your React components? If so, keep in mind the styling library is different.
6 Views