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

Brady Aiello

01/25/2023, 5:08 AM
Is it possible for a compose web application to consume composables from a compose multiplatform Gradle module (with android, desktop, web, etc.)? I have been able to do this fine with Android and JVM, but not Web. When my
web
module tries to consume a simple composable from my
common-compose
module, I get:
Copy code
"IllegalStateException: CompositionLocal LocalDensity not present
    at noLocalProvidedFor (webpack-internal:///./kotlin/androidx-ui.js:26963:11)
    at LocalDensity$lambda (webpack-internal:///./kotlin/androidx-ui.js:26986:5)
    at UnsafeLazyImpl.get_value_j01efc_k$ (webpack-internal:///./kotlin/kotlin-kotlin-stdlib-js-ir.js:10896:56)
    at _get_current__qcrdxk (webpack-internal:///./kotlin/androidx-runtime.js:17072:42)
    at LazyValueHolder.get_value_j01efc_k$ (webpack-internal:///./kotlin/androidx-runtime.js:17079:12)
    at resolveCompositionLocal (webpack-internal:///./kotlin/androidx-runtime.js:1957:52)
    at ComposerImpl.consume_11nid3_k$ (webpack-internal:///./kotlin/androidx-runtime.js:4687:12)
    at eval (webpack-internal:///./kotlin/androidx-material.js:4025:34)
    at ComposableLambdaImpl.invoke_6harzl_k$ (webpack-internal:///./kotlin/androidx-runtime.js:33330:92)
    at eval (webpack-internal:///./kotlin/androidx-material.js:4118:25)"
o

Oleksandr Karpovich [JB]

01/25/2023, 11:56 AM
here is a thread with a similar question - https://kotlinlang.slack.com/archives/C01F2HV7868/p1674443083908619 Short answer: HTML based Composables can't use the composables from compose.material, foundation, etc (canvas based) directly. There is no out of a box solution to combine HTML based with Canvas based right now, although it should be possible.
s

shikasd

01/25/2023, 2:15 PM
We introduced
@ComposableTargetMarker
some time ago which should help to avoid mixing stuff like that Not sure if Web composables are using it yet, but maybe makes sense to add those if they are not :)
b

Brady Aiello

01/25/2023, 6:22 PM
Right on. Thank you both so much! 🙏
16 Views