Hello, how can I use an `Image` resource in compos...
# compose-web
d
Hello, how can I use an
Image
resource in compose-web?
This is how I load it in the
jvm
target:
Copy code
@Composable
private fun FileImage(item: FileSystemItemData) {
    val resourcePath = remember(item.isDirectory) {
        when {
            item.isDirectory -> "folder-icon.png"
            else -> "gcode.png"
        }
    }

    Image(
        modifier = Modifier.width(40.dp).height(40.dp),
        contentDescription = "",
        bitmap = useResource(resourcePath) { loadImageBitmap(it) }
    )
}
but
useResource
and
loadImageBitmap
are not available for the
js
target
j
Use is like this
resource('path to image').rememberImageBitmap()
then add it to
Image()
d
I can't find the
resource
method
j
Add
implementation(compose.components.resources
) in your commonMain section of the build.gradle.kts file
👀 1
Or you can place it in the jsMain too if you're only targeting js
d
thank you, I fixed the import