Questions tagged [kotlin-js]
The kotlin-js tag has no usage guidance.
281
questions
1
vote
1
answer
79
views
Quarkus returns 415 Unsupported Media Type with multipart when called from a ktor client in kotlin/js
I have this Quarkus endpoint:
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@RolesAllowed("ADMIN")
suspend fun createPost(
@Context ctx: SecurityContext,
...
0
votes
0
answers
22
views
How to use JS/React Libraries with Kotlin/JS?
I’m exploring Kotlin/JS at the moment and still very new to it.
Currently I’m exploring React with Kotlin/JS. I’m wondering if there are any step by step guide on how I could use and integrate ...
0
votes
0
answers
13
views
how to initialize style in i html element in kotlin/js?
val Welcome = FC<WelcomeProps> { props ->
var name by useState(props.name)
div {
css {
width = 100.pct
height = 500.px
margin = 0.px
padding = 0.px
...
0
votes
0
answers
22
views
Using Splide Javascript Library in KotlinJS frontend
I'm trying to find a kotlin based framework for a web-app and decided to try KVision as frontend framework (https://kvision.io).
I tried to use an external javascript library called Splide (https://...
0
votes
1
answer
15
views
Kotlin multiplatform js react - how to use redux Store Provider?
While using kotlin-multiplatform/js with react-redux, after the release, old way of setting-up the Redux Store Provider is deprecated (and may work only in kotlin-react-legacy lib). It was not easy to ...
2
votes
0
answers
56
views
Is it possible to use in JavaScript interface created in Kotlin.js?
I try to reduce my codebase by using a KMM library compiled for Jvm, Android and Javascript.
The simplest code in Kotlin:
@JsExport
actual interface DataTransferObject {
actual val _type: String
...
0
votes
0
answers
18
views
When using kotlinx.html's DSL to create HTML, (how) is it possible to refer to nested elements?
I'm using kotlinx.html's DSL to create HTML, and I need references to some of the elements created (to refer to them in event handlers etc.). However, while the functions used directly within the ...
0
votes
0
answers
72
views
How to call suspending function in class that implements an interface with non-suspending functions in Kotlin/JS
I'm writing a Kotlin Multiplatform library using version 1.9.0-RC, and targeting JVM, Native, and JavaScript.
I want to create a class that implements an interface from a dependency.
// this interface ...
0
votes
1
answer
49
views
No output when compiling kotlin-js IR using kotlinc cli
I'm trying to compile a kotlin file test.kt using kotlinc-js:
fun main() {
println("Hello world!")
val a = add(7, 22)
println("Added to get $a")
}
fun add(x: Int, y: ...
0
votes
0
answers
7
views
How do I get toLocaleTimeString() to work for a timezone that isn't mine?
I am using KotlinJS and react, and I have been trying to make a time widget, but I cannot display anything other than est (my time zone) with the toLocaleTimeString() method
import csstype.FontWeight
...
0
votes
0
answers
41
views
How to call suspend fun in kotlin/js/react, and update State
I have a suspend fun, and want to append its result to a list (in State) when it return.
Following code dose not work.
Assuming I click 'short' 3 times, and 'long' 1 time, then, in 3000 millisecond (...
0
votes
0
answers
29
views
Why this Kotlin/js react code cannot compile?
Why this Kotlin/js react code cannot compile? It seems that type inference does not work well.
I just want to add some more complex object to Context, but looks like type inference failed to work.
...
0
votes
1
answer
39
views
Kotlin/JS browserDevelopmentWebpack doesn't generates build/distributions
I am trying to bundle kotlin/js artifacts through webpack, in a Kotlin/JS project.
The documentation here Set up a Kotlin/JS project says that
For building executable JavaScript artifacts through ...
0
votes
0
answers
34
views
Function createKType not found
I am trying to get Custom Elements running with Kotlin/Wasm, but when compiling I encounter this exception:
> Task :compileDevelopmentExecutableKotlinWasm FAILED
e: java.lang....
0
votes
0
answers
34
views
I cannot make the time on my Kotlin-JS React website update each second?
I have an issue where the time on my KotlinJS React web page doesn't update unless it is reloaded. What is the proper way to reload data at a set interval.
import csstype.*
import emotion.react.css
...
0
votes
1
answer
65
views
Clipboard copy with formatting in Kotlin/JS
I am working on a Kotlin multiplatform project.
I want to support copy action with formatting.
There are a plenty of page in the web implementing it in javascript. All of them are almost same and do ...
0
votes
0
answers
48
views
Trouble creating a KotlinJS component that returns React context - how can I fix the 'return not allowed here' error?
I am working in code immigration that is written in reactjs to kotlinjs with react.
I have problem with react context issues.
In kotlinjs I have to create a component that should return Context.
The ...
1
vote
0
answers
90
views
Using external CSS library in Kotlin/JS
I am not a frontend developer and not familiar with npm, yarn and this sort of tools.
However I want to render some data in a Kotlin/JS project.
Particularly, I want to use font-awesome icons in my ...
1
vote
0
answers
92
views
Specify module kind for kotlin/js compiler in multiplatform project
As stated in here, it is possible to compile Kotlin/JS to different modules. However, proposed solution doesn't work. When trying to add this block of code:
tasks.named<KotlinJsCompile>("...
1
vote
2
answers
46
views
window.getSelection() in Kotlin/JS
There is window.getSelection() in JS.
What is the equivalent in Kotlin/JS?
There is nothing in Kotlin Window API.
0
votes
0
answers
96
views
In Kotlin/JS(Kotlin Multiplatform), how can I get the API Key listed in local.properties?
In Kotlin/JS, how can I get the API Key written in local.properties?
There is a lot of information on how to get the API Key described in local.properties in Android, but I don't know how to get it in ...
0
votes
1
answer
59
views
How to integrate Google GSI with Kotlin/JS
Am trying to implement Google on-tap sign-in in a Kotlin/Js project.
Is there any kotlin-wrapper like library available to use https://accounts.google.com/gsi/client in a Kotlin/Js project?
Or is ...
0
votes
0
answers
109
views
How to use Composables from common in Compose Web?
I made a simple Compose Web project using the getting started guide. It works when just using the Web API, so Composables like Div and Span.
However, the whole point of multiplatform is being able to ...
0
votes
0
answers
44
views
trying to wrap react-cookie in kotlin js react project which uses constructor props
I am trying to use react-cookie with the latest kotlin wrappers and 1.8.10
and am having trouble with the CookieProvider class provided by the npm library
it defines the class with the constructor ...
0
votes
0
answers
28
views
Select All Checkboxes causes individual checkboxes to lose functionality. Kotlin/JS
Hello Everyone I have this checkbox working for select all. But the individual ones don't click. How do I fix it? Title.ET is a list of Strings. checkAll uses useState with the initial value of ...
0
votes
1
answer
71
views
Kotlin/JS - external val from npm package is undefined
I'm trying to use React components from the CKEditor package in my kotlin/js code.
In javascript, I would import these like this:
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ...
0
votes
0
answers
84
views
How to generate typescript definitions from kotlin DTO in maven
We have an api module in our maven project running on kotlin 1.8.10 that exposes and expects quite a few DTO objects as payloads (both for post and for get)
ie
data class AttachmentDto(
val id: ...
2
votes
1
answer
160
views
How to add a react component from an external js library?
I'm trying to add a component from an external library to my react project, but I get an error when I open the page in the browser:
Error: Element type is invalid: expected a string (for built-in ...
1
vote
1
answer
54
views
Kotlin/JS JAR-files contains no JS-files when downloaded manually. Why?
If I download a Kotlin/JS JAR-files manually from https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-serialization-core/1.3.3/pom or https://mvnrepository.com/artifact/org.jetbrains....
0
votes
1
answer
57
views
Using functions that take an interface without creating a class the implements said interface
building alot of binding libraries for a kotlin js project.
i have a ton of interfaces that look like this:
external interface FullscreenControlProps {
var containerId: String?
var position: ...
1
vote
1
answer
260
views
How do I call a suspend function from a React button onClick event in Kotlin/JS?
I want to fetch some data when a button is pressed. I know how to do it using promises and continuations (see the sample below) but I'd like to learn how to do it using suspend functions.
As an ...
0
votes
0
answers
50
views
How to use lambdas like in Kotlin-JS?
I'm writing library on Kotlin, that builds file from each function that returned string. I get stuck on writing lambda(or something like this) that have inside many fun : String. Need to realize this ...
1
vote
1
answer
447
views
Problems with Kotlin react router dom element attribuute for binding a react component to URL
I'm currently working on a sample application to learn Kotlin/Js with the react library. When using the normal JSX syntax, a component can be set to be triggered when a specific URL hits using the ...
0
votes
0
answers
23
views
Issues with Debugging Kotlin/Js Project on Chrome
So I recently started experimenting with Kotlin/Js with react and one of the issues that I ran into involves some errors regarding Uncaught Type Error at RouterDOM but all the sources I get are ...
0
votes
1
answer
77
views
Need help creating a kotlin js wrapper for mapbox-gl-draw
so i am trying to create a wrapper for mapbox-gl-draw in my kotlin react project.
my starter wrapper looks like this
@JsName("default")
external fun mapboxDraw()
i am trying to base it off ...
1
vote
1
answer
121
views
Transforming a Flow<Byte> to a Flow<String> in Kotlin
Consider I have a cold source of UTF-8 bytes (e. g.: reading a file on disk, or the body of an HTTP response), in a form of a Flow<Byte>. How do I convert the above source to a flow of strings?
...
0
votes
1
answer
104
views
Compiling for both Kotlin/Java and Kotlin/JS?
I'd like to write some of my code in Kotlin such that it can be used by both a JVM-based backend and a JS-based frontend.
To do the former (with the new IR complier), the classes have to be annotated ...
1
vote
0
answers
53
views
KotlinJs: Unable to run jsBrowserTest in Google Cloudbuild due to "ReferenceError: setMetadataFor is not defined"
We have a very simple test in kotlinJs to check that a function we have in Javascript is read into kotlin and returns something:
JS code:
function: makeKey = (num) => { return 1000 + num }
Kotlin ...
1
vote
2
answers
134
views
Kotlin Multiplatform/JS Unresolved reference Document.evaluate()
Context: Kotlin Multiplatform JavaScript.
I'm trying to use a Document.evaluate() but getting Unresolved reference: evaluate and Unresolved reference: XPathResult.
import org.w3c.dom.Document
import ...
1
vote
1
answer
194
views
How to pass pass values to constructor when instantiate kotlin class
Assuming I have a class like this
class Foo(private val someVal: String) : RComponent<SomeProp, SomeState>(){
...
}
which I instantiate like so
child(
Foo::class
) {
attrs.bar = props....
0
votes
0
answers
77
views
KMM & KMP share business logic with react app
We are trying to build single business logic with kmm to share it with ios and android and react project
IOS Project contains
swiftUI
cocoapods
react
typescript and react framework
package.json
...
1
vote
1
answer
68
views
How can I add my own version of dukat in intellij idea
I am trying to generate external Declaration for a NPM package but it is giving errors
But when I tried the same with dukat@next version it worked
Tell me either how can I include my generated ...
0
votes
1
answer
44
views
why doesn't "is" operator honor inheritance in kotlinjs
I'm developing a kotlinjs react project.
plugins {
kotlin("js") version "1.8.0"
}
and I've written this class:
class Percentage(private val number: Number) : Number() {
...
0
votes
0
answers
67
views
Could not determine the dependencies of task ':kotlinNodeJsSetup' - Kotlin Multiplatform
Build was configured to prefer settings repositories over project repositories but repository 'Node Distributions at https://nodejs.org/dist' was added by unknown code
Could not determine the ...
1
vote
1
answer
172
views
kotlinc-js 1.8 doesn't seem to support IR
When compiling using the kotlin 1.8 sdk, for example :
kotlinc-js -version
One gets the following:
info: kotlinc-js 1.8.0 (JRE 19.0.1)
error: ==========
This project currently uses the Kotlin/JS ...
0
votes
1
answer
186
views
callback function called from coroutine does not run with KotlinJS
I am trying to write a Kotlin function that executes a HTTP request, then gives the result back to JavaScript.
Because with the IR compiler I cannot use a suspended function from JavaScript, I am ...
0
votes
0
answers
20
views
kotlin member reference - grabbing child object data
(using kotlin JS btw)
if i have a class that looks like this
data class AppUserDTO(
override val email:String,
override val client: DTOMin? = null
)
and the DTOmin looks like
data class ...
0
votes
0
answers
117
views
Possible to create a kotlin js app gradle config without webpack/npm/yarn?
Is it possible to create a gradle config that uses the kotlin multiplatform plugin to create a project with a kotlin js client (and ktor/jvm back end) that does required the webpack/npm/yarn ...
0
votes
1
answer
191
views
Using async func in Compose Web
I should use Ktor client in Compose Web. But, It can't be called in Compose Web due to async/non-async problem.
Environment is template project made by IntelliJ IDEA.
First, I use this:
val client=...
1
vote
1
answer
276
views
Kotlin/JS fails to build inside of Docker because of backslashes in package.json
I have a multi-project gradle build that I'm trying to build inside of docker. One of the projects is a Kotlin multiplatform project that builds to JVM and JS. Building the library is fine on my ...