https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
react
  • h

    hannesstruss

    10/04/2020, 11:18 AM
    I couldn't find any info on this, are media queries supported in kotlin-styled?
    a
    • 2
    • 4
  • b

    Björn Mayer

    10/25/2020, 1:35 PM
    Heyho, is there a way to set default props in Kotlin React? https://reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values
    a
    • 2
    • 2
  • j

    Joost Klitsie

    10/29/2020, 6:27 PM
    Hi all! How do I modify such a thing to kotlin:
    <ReactPlayer
                  config={{
                    file: {
                      hlsOptions: {
                        forceHLS: true,
                        debug: false,
                        xhrSetup: function(xhr, url) {
                          if (needsAuth(url)) {
                            xhr.setRequestHeader('Authorization', getToken())
                          }
                        },
                      },
                    },
                  }}
                />
    I saw the things on https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/07_Using_Packages_From_NPM but I can't wrap my head around it
    a
    • 2
    • 13
  • m

    Marc Knaup

    11/16/2020, 6:49 PM
    How do you cancel coroutines when a (functional) component is unmounted? My first shot. Feels weird 🤔
    @Suppress("unused")
    fun RBuilder.useCoroutineScope(): CoroutineScope {
        val (scope) = useState { CoroutineScope(GlobalScope.newCoroutineContext(Dispatchers.Unconfined)) }
        useEffectWithCleanup(emptyList()) { { scope.cancel() } }
        return scope
    }
    In component:
    val scope = useCoroutineScope()
    scope.launch { … }
    r
    j
    • 3
    • 6
  • b

    Big Chungus

    11/25/2020, 11:27 AM
    What's the difference between these 2?
    #1
    fun RBuilder.Component(prop1:String, prop2:String) {}
    
    #2
    interface ComponentProps: RProps {
      var prop1: String
      var prop2: String
    }
    val Component = rFunction<ComponentProps>("Component"){}
    m
    • 2
    • 10
  • a

    andylamax

    11/25/2020, 6:43 PM
    Has any one attempted to provide wrapper's for
    Enzyme
    ? Before I go down this road?
    c
    • 2
    • 2
  • i

    igor.wojda

    12/15/2020, 8:15 PM
    General question about React and Kotlin: 1. how would you compare current state of
    React + Kotlin
    vs
    React + JS/TS
    ? 2. Is it worth a hustle to use
    React + Kotlin
    only because I like
    Kotlin
    ? 3. How mature it is in terms of tools and external libraries compatibility? 4. What are the main disadvantages currently?
    m
    a
    c
    • 4
    • 13
  • a

    andylamax

    12/20/2020, 3:53 AM
    I think I found a bug (Not sure) When extending
    RComponent
    and you
    override
    methods with arguments that are called from
    react
    directly (i.e.
    componentDidUpdate(prevProps,prevState,snapshot)
    or
    componentWillReceiveProps(nextProps)
    ), generated
    javascript
    code always throws a
    ClassCastException
    . Lets take a look at
    componentWillReceiveProps(next)
    . The
    IR Compiler
    generates
    javascript
    code similar to this
    PaginatedGridComp.prototype.componentWillReceiveProps = function (nextProps) {
      return this.componentWillReceiveProps_17(nextProps instanceof Props_19 ? nextProps : THROW_CCE());
    };
    Since
    react
    creates
    nextProps
    internally, the check
    nextProps instanceof Props_19
    always fails. Hence it throws
    CCE
    Is there a work around to this problem? IR Compiler Backend
    m
    • 2
    • 3
  • e

    epabst

    12/29/2020, 5:25 AM
    I'm trying to make an uncontrolled component for a number input with kotlin-react. I need it because I want to format the text input as currency (e.g. 5 becomes "5.00"), and with it being a controlled component, I can't edit the cents very well. When I delete the last "0" the code puts it back and moves my cursor. However, I have no idea how to do an uncontrolled component in Kotlin. Any help or examples of this?
    t
    • 2
    • 6
  • c

    cfnz

    01/21/2021, 2:09 AM
    Hi, I am trying to wrap the Rating component of Material UI in my Kotlin Material UI Wrapper project (Muirwik). Have got the basics working, but I am trying to handle the example with custom icons and colors. Custom icons sorted, but how do I handled the custom styles? JS:
    const StyledRating = withStyles({
      iconFilled: {
        color: '#ff6d75',
      },
      iconHover: {
        color: '#ff3d47',
      },
    })(Rating);
    
    export default function CustomizedRatings() {
      return (
        <div>
        ...
             <StyledRating
              name="customized-color"
              defaultValue={2}
              getLabelText={(value: number) => `${value} Heart${value !== 1 ? 's' : ''}`}
              precision={0.5}
              icon={<FavoriteIcon fontSize="inherit" />}
            />
       ...
    How would I use/pass these StyledRatings styles to my component? Kotlin - how do I add the iconFilled prop or style?:
    ...
        mRating("customized-empty", value, precision = 0.5, onChange = { _, newValue -> valueCustom = newValue },
            icon = mIcon("favorite", fontSize = MIconFontSize.inherit, addAsChild = false, color = MIconColor.inherit) {
                css {
                    ???
                }
            }
        )
    b
    • 2
    • 9
  • b

    Big Chungus

    02/04/2021, 8:17 AM
    What's the difference between functionalComponent() and rFunction()?
    a
    a
    t
    • 4
    • 10
  • m

    Manel Martos Roldan

    02/11/2021, 9:32 AM
    Hi! Which are the available approaches for adding unit testing facilities into a React app fully written in Kotlin?
    ➕ 3
    e
    • 2
    • 2
  • t

    Timo Gruen

    02/13/2021, 10:22 AM
    Hi folks, I’m currently starting to develop a Admin UI for a Cloud platform I recently created. Any advice for using Kotlin (React) over TypeScript (React). The Framework i wanted to use is Material UI. How mature is Kotlin (React) already? (Which major pain points would I stumble across?)
    b
    j
    • 3
    • 7
  • n

    Nicodemus Ojwee

    02/22/2021, 9:22 PM
    Hello everyone. I took time off my busy work schedule and came up with some Kotlin wrappers for React Native and other related libraries. I also came up with a cli tool to generate a React Native application with Kotlin. You can check out the projects on My Github, give them some stars and use them for study or research purposes. Maybe someone here can learn a thing or two and also create their own Kotlin wrapper libraries and build/grow this community. NOTE: Everything is experimental but works 🙃 Here are the links to the repositories: 1. Kotlin React Native CLI tool 2. Kotlin Wrapper for React Native Core 3. Kotlin Wrapper for React Native Base 4. Kotlin Wrapper for React Native Navigation 5. Kotlin Wrapper for React Native Async Storage
    :kotlin-intensifies: 4
    👍 1
    b
    • 2
    • 2
  • w

    willyrs

    03/05/2021, 9:31 AM
    Hi all, I'm trying to setup the app routes but they don't work. The render is:
    override fun RBuilder.render() {
        browserRouter {
            div {
                ul {
                    li {
                        routeLink("/") { +"Home" }
                    }
                    li {
                        routeLink("/test") { +"Test" }
                    }
                }
    
                switch {
                    route("/") {
                        h1 {
                            +"Home path"
                        }
                    }
                    route("/test") {
                        h1 {
                            +"Test path"
                        }
                    }
                }
            }
        }
    }
    What happens: When I start the website, it prints "Home path". The I press "Test" in the menu, the url changes to http://localhost:8080/test but the header still says "Home path". If I then press F5 I have the error "Cannot GET /test". What could be the problem? It seems the same as the tutorial that I'm looking at
    c
    m
    • 3
    • 11
  • m

    Marc Knaup

    03/12/2021, 5:58 PM
    I’ve released fluid-react 0.9.8 with support for react-helmet-async (dynamic page metadata).
    🎉 3
    👍 1
    :kotlin-intensifies: 1
    b
    • 2
    • 3
  • m

    Marc Knaup

    03/16/2021, 1:00 PM
    How do you handle lazy loading? I’m experimenting with various approaches 🤔
    t
    • 2
    • 4
  • e

    Erdem

    03/16/2021, 3:54 PM
    Hello. I am having trouble with react state. So basically I am handling a list to show outside of component and updating the state via callback like this.
    val (state, setState) = useState(emptyList<Post>())
    
    provider.observePosts { list -> setState(list) }
    With this method the ui only updates once, however if I set state like this
    setState(list.toList())
    it works fine. I am concerning about performance. How should I update my list?
    m
    • 2
    • 1
  • r

    Robert Jaros

    03/16/2021, 4:21 PM
    Why JB decided to publish
    kotlin-wrappers
    artifacts to JB Space and not to Maven Central?
    ➕ 2
    t
    s
    b
    • 4
    • 9
  • a

    Alexey Artemiev

    03/31/2021, 5:54 PM
    Hello! With kotlin-styled the following
    val x by css {
      backgroundImage = require("src/main/resources/image.png")
    }
    gives an error
    Module 'src/main/resources/image.png' not found
    Moving file to main/kotlin/... and changing to relative path from the source file dir gives the same "not found" error. Using JsModule gives the same error too. The advice
    require("image.png")
    doesn't work either. Where should resources be placed, and how to reference them by relative path in kotlin/js react app? Please, help! Google gives only 2-year (and more) old advices which don't help, because kotlin/js seems to have changed much recently.
    t
    • 2
    • 2
  • r

    Robert Jaros

    04/03/2021, 10:11 AM
    Hi, how to add simple inline style attribute with kotlin-react? I don't want to generate css classes like it is done with
    kotlin-styled
    .
    • 1
    • 2
  • n

    Nicodemus Ojwee

    04/06/2021, 7:11 PM
    I am trying to use the library html-react-parser in my React application that uses IR backend. I got the code from my old project that was not using IR backend, however it seems not to work like before. The error i get in the console says:
    Uncaught TypeError: HTMLReactParser is not a function
    This is how the module is defined.
    @file:JsModule("html-react-parser")
    @file:JsNonModule
    @file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")
    
    package libs
    
    import react.ReactElement
    
    external interface HTMLReactParserOptions {
        var htmlparser2: Any? /* ParserOptions & DomHandlerOptions */
            get() = definedExternally
            set(value) = definedExternally
        var library: dynamic
            get() = definedExternally
            set(value) = definedExternally
        var replace: ((domNode: dynamic /* Comment | Element | Node | ProcessingInstruction | Text */) -> dynamic)?
            get() = definedExternally
            set(value) = definedExternally
        var trim: Boolean?
            get() = definedExternally
            set(value) = definedExternally
    }
    
    @JsName("HTMLReactParser")
    external fun parse(html: String, options: HTMLReactParserOptions = definedExternally): ReactElement
    t
    • 2
    • 16
  • r

    rishi jha

    04/15/2021, 4:45 PM
    How do I use react native with kotlin
    b
    r
    m
    • 4
    • 12
  • p

    Paul SOUTEYRAT

    04/17/2021, 11:11 AM
    Hi everyone, I was wondering if there was a way to make a generic react component in Kotlin/JS. The following minimal example seems to be working:
    interface MyGenericCompProps<T> : RProps
    
    fun <T> myGenericComp() = { props: MyGenericCompProps<T> ->
        buildElement {
            div {
                +"Generic component"
            }
        }
    }
    
    val genericCompContainer = functionalComponent<RProps> {
        child(myGenericComp<Any>())
    }
    But I am not sure if it's a good way to make a component. Do any of you see issues with my example ?
    t
    • 2
    • 10
  • a

    andylamax

    05/01/2021, 9:37 PM
    Hello good people, I have been getting
    Could not find "kotlinx-extensions" in [~/.local/share/kotlin/daemon]
    . I checked the dependencies and I can find dependencies from the space repository. Even
    ./gradlew dependencies --configuration runtimeClasstimepath
    shows the dependency is resolved. What am I missing?
    t
    • 2
    • 9
  • r

    Robert Jaros

    05/05/2021, 4:22 PM
    @Sebastian Aigner Any chance we will see
    kotlin-wrappers
    artifacts for Kotlin 1.5.0 published to Maven Central soon?
    🔥 3
    :kotlin: 4
    a
    j
    +3
    • 6
    • 10
  • b

    Big Chungus

    05/12/2021, 1:00 PM
    Looking for someone from JB to shed some light on this issue:
    Currently there are multiple ways of doing the same react stuff in kotlin-react (e.g. rComponent() vs functionalComponent()). My understanding (based on various threads on this in the past) is that this came to be mainly because of the way kreact evolved over the years and more mature APIs surfaced. Have you had any thoughts of cleaning this up with deprecations to reduce confusion for new folks trying kreact out?
    🤷‍♂️ 2
    t
    • 2
    • 1
  • a

    andylamax

    06/07/2021, 3:52 AM
    I don't know when this happened, but I like that RBuilder is now an interface.
    t
    • 2
    • 1
  • r

    Robert Jaros

    06/13/2021, 11:03 AM
    Why was this change introduced? https://github.com/JetBrains/kotlin-wrappers/commit/fdb3bad0ef88566ffb857323630fbd1002613caa#diff-bd3e93f85ad37698fd0a6ac70811de3de7794a05add52da53ae6965f6f00cf52
    t
    s
    • 3
    • 11
  • r

    Roman Vasilyev

    07/04/2021, 7:26 AM
    my current kotlin js always generates 
    reactJs.js
     is it possible to change config to get 
    reactJs.somerandomhash.js
     ?
    t
    • 2
    • 1
Powered by Linen
Title
r

Roman Vasilyev

07/04/2021, 7:26 AM
my current kotlin js always generates 
reactJs.js
 is it possible to change config to get 
reactJs.somerandomhash.js
 ?
t

turansky

07/27/2021, 3:23 PM
Webpack
config.output.fileName
?
View count: 5