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
  • p

    Paul N

    04/29/2020, 7:46 AM
    I'm trying to use a bootstrap drop down: Here's my wrapper code:
    @file:JsModule("react-bootstrap")
    @file:JsNonModule
    
    import react.*
    
    @JsName("Dropdown")
    external val Dropdown: RClass<DropDownProps>
    
    external interface DropDownProps : RProps {
        var bsClass: String?
        var componentClass: Any?
        var disabled: Boolean?
        var dropup: Boolean?
        var id: String
        var onClose: Function<*>?
        var onSelect: Any?
        var onToggle: ((isOpen: Boolean) -> Unit)?
        var open: Boolean?
        var pullRight: Boolean?
        var role: String?
    }
    
    @JsName("DropdownMenu")
    external val DropdownMenu: RClass<DropdownMenuProps>
    
    external interface DropdownMenuProps : RProps {
        var labelledBy: dynamic /* String | Number */
        var onClose: Function<*>?
        var onSelect: Any?
        var open: Boolean?
        var pullRight: Boolean?
    
    }
    
    @JsName("DropdownItem")
    external val DropdownItem: RClass<DropDownItemProps>
    
    external interface DropDownItemProps : RProps {
        var eventKey: String
        var href: String
    }
    And here's my component that uses it:
    class GroupList: RComponent<GroupListProps, RState>() {
        override fun RBuilder.render() {
    
            console.log("Dropdown",Dropdown)
            console.log("Dropdown menu is",DropdownMenu)
            console.log("Dropdown item",DropdownItem)
           
            Dropdown {
                DropdownMenu {
                    props.groups.forEach {
                        DropdownItem {
                            attrs.eventKey = it.id
                            +it.description
                        }
                    }
                }
            }
        }
    }
    The console log shows DropDownMenu as being undefined (the other two are OK), resulting in my code failing:
    DevTools failed to load SourceMap: Could not load content for <chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/include.preload.js.map>: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
    GroupList.kt?2322:20 Dropdown {$$typeof: Symbol(react.forward_ref), displayName: "Dropdown", defaultProps: {…}, Toggle: {…}, render: ƒ, …}
    GroupList.kt?2322:21 Dropdown menu undefined
    GroupList.kt?2322:22 Dropdown item {$$typeof: Symbol(react.forward_ref), displayName: "DropdownItem", defaultProps: {…}, render: ƒ}
    react.development.js?6008:315 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
    
    Check the render method of `GroupList`.
        in GroupList (created by App)
        in div (created by styled.div)
        in styled.div (created by App)
        in App
    Does anyone know what I'm doing wrong ? Are there any Kotlin wrappers for basic HTML components such as drop downs etc, or is my approach of writing wrappers from scratch (with a little help from Dukat) the only way ?
    t
    • 2
    • 3
  • b

    bartosz.malkowski

    05/04/2020, 2:15 PM
    Hi! Is there any kotlin wrapper for react Bootstrap or RingUI? Or I have to do everything myself?
    👍 1
    u
    b
    +2
    • 5
    • 7
  • b

    Björn Mayer

    05/06/2020, 9:55 PM
    Does anyone have an example where
    forwardRef
    is used in Kotlin React?
    t
    • 2
    • 1
  • s

    Siddhartha Juluru

    05/11/2020, 10:49 PM
    Does anyone know how to fix the React Redux/Redux error where it says "The previous state received by the reducer has an unexpected type of "Object""
    t
    • 2
    • 18
  • i

    iari

    05/13/2020, 8:26 AM
    When I try to create a context with
    val LoginContext = createContext<LoginContextData>()
    I get the following error
    When accessing module declarations from UMD, they must be marked by both @JsModule and @JsNonModule
    What's wrong?
    b
    t
    i
    • 4
    • 5
  • b

    Björn Mayer

    05/18/2020, 1:47 PM
    Is it just me or is every
    cloneElement
    just broken?
    cloneElement<Button.Props>(el) {
        // nothing here
    }
    results in
    Cannot define property kotlinHashCodeValue$, object is not extensible
    Same result with all the other
    cloneElement
    implementations. I am trying to clone a
    ReactElement
    and while doing that override some props.
    • 1
    • 1
  • s

    Sourabh Rawat

    05/25/2020, 5:40 AM
    how to use styles with React components? I tried importing
    styled
    function from material UI but its not working. Can someone provide an example on how to do it, with material UI if possible?
    n
    • 2
    • 2
  • b

    Björn Mayer

    05/26/2020, 7:01 PM
    Is there a way to create a child with predefined properties, which I can then override? Like so
    child(Button::class.rClass, buttonProps) {
        attrs {
            onClick = this@ButtonGroup::buttonClicked
            active = index in state.activeButtons
         }
    }
    This one fails because every property of
    buttonProps
    is readOnly
    s
    • 2
    • 2
  • b

    Björn Mayer

    05/31/2020, 2:45 PM
    React is messing with me. I have a checkbox which gets its “checked”-state from my component state:
    checked = state.active == true
    I do have a custom
    onChange
    handler, which sets the state:
    val target = event.target as HTMLInputElement
    
    setState {
        active = target.checked
    }
    When checking the checkbox, react throws this message:
    react_devtools_backend.js:6 Warning: A component is changing an uncontrolled input of type checkbox to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: <https://fb.me/react-controlled-components>
    ✅ 1
    t
    s
    • 3
    • 4
  • p

    Paul N

    06/02/2020, 3:29 PM
    A general question on Kotlin / React - is it ready for production ? All I need to do is write a simple CRUD application with a few drop downs, checkboxes, text fields and so on. Are there mature wrapper libraries for basic form components ?
    b
    i
    • 3
    • 6
  • c

    christophsturm

    06/08/2020, 3:32 PM
    how can I use something like http://recharts.org/ with kotlin/js? all the demos on their site seem to use jsx
    r
    • 2
    • 61
  • f

    frank

    06/13/2020, 2:12 PM
    Some equivalent in react for appendchild(). I try with state but don't work. Any suggestion or tips?
    t
    • 2
    • 8
  • b

    Big Chungus

    06/14/2020, 4:07 PM
    Does anyone know if it's possible to implement React's
    useState
    hook in pure kotlin? Or does it rely on JS's
    var
    magic?
    f
    h
    e
    • 4
    • 16
  • f

    frank

    06/15/2020, 5:16 AM
    Any sample of conditional rendering in Class component? I try with
    child()
    or directly passing my fuctional component but dont work.
    class listMsg : RComponent<msgListProps, msgListState>() {
            override fun RBuilder.render() {
                props.msg.forEachIndexed { index, msg ->
                    when(msg.type){
                        "log" -> itemLog //Dont work
                        else ->  li {
                            attrs.key = index.toString()
                            div(classes = "receivedMessages") {
                                span(classes = "filledInitials") {
                                    +getInitials(msg.nickName)
                                }
                                span(classes = "chatMessage") {
                                    +msg.msg
                                }
                            }
                        }
                    }
                }
            }
    }
    
    val itemLog = functionalComponent<itemLogProps>{ props ->
                li(classes = "log") {
                    p {
                        +props.msg
                    }
                }
    }
    t
    • 2
    • 4
  • c

    christophsturm

    06/19/2020, 9:36 AM
    are react TestUtils part of the kotlin react wrappers? is there an example for unit testing a react component in kotlin?
    😞 1
    🇳🇴 1
    t
    e
    • 3
    • 14
  • f

    frank

    06/21/2020, 8:44 PM
    I'm testing Hook states. When I declare
    onSendMessageClicked()
    function inside of my functionalComponent the elements can't find it and I need to declare it outside.
    val chatWindowComponent = functionalComponent<ChatMsgListProps>{ props ->
            val (mensajes,setMensajes) = useState(arrayOf<ReactElement>())
    
            div(classes = "chatWindow") {
                    div {
                        button(classes = "sendMessageButton") {
                            +"Send Message"
                            attrs.type = ButtonType.button
                            attrs.onClickFunction = onSendMessageClicked()
                        }
                    }
            }
    
            fun onSendMessageClicked(): (Event) -> Unit {
                return {
                    //Code
                }
            }
        }
    The disadvantage of declaring
    onSendMessageClicked()
    outside is that I need to send
    setState
    in all functions that use it. Alternatives to this?
    fun onSendMessageClicked(setMsg: RSetState<Array<ReactElement>>): (Event) -> Unit {
                return {
                    //Something(setMsg)
                }
    }
    a
    • 2
    • 15
  • a

    andylamax

    06/30/2020, 10:13 PM
    The current verbosity in creating functional components in kotlin-react is uncanny. I would have to create the function
    external interface DumbProps {
       var name: String
    }
    
    val DumbComp = functionalComponent<DumbProps> {
        div { +"Hi, I am ${it.name}" }
    }
    Then, I would have to create an extension for RBuilder like so
    fun RBuilder.DumbComp(props: DumbProps,handler:RHandler<DumbProps>) = child(DumbComp,props,handler)
    This makes the usage of functional components and hooks so verbose. Advice: RBuilder should add a member function to ease use of functional components and hooks like so
    class RBuilder{
      . . .
      operator fun <P : RProps> FunctionalComponent<P>.invoke(
        props: P = jsObject(),
        handler: RBuilder.(P) -> Unit
      ) = child(this, props, handler)
      . . .
    }
    So that now, I can just go and call
    DumbComp {
       attrs.name = "Andy" 
    }
    👍 4
    f
    • 2
    • 2
  • j

    Joost Klitsie

    07/08/2020, 11:44 AM
    Hi all! Can some explain to me how to get the Context.Provider and useContext(Context) working? For me it doesn't really do what I expect from it. I expect that if I call code like this, where I nest the useContext within a Provider call, that useContext will return the value what is within the provider call. However, it shows the initial value there
    fun main(args: Array<String>) {
        render(document.getElementById("root")) {
            child(App)
        }
    }
    
    val SomeContext = createContext(1)
    
    val App = functionalComponent<RProps> {
        SomeContext.Provider(5) {
            typographyH1 {
                +useContext(SomeContext).toString() // Actually shows '1'
            }
        }
    }
    a
    • 2
    • 11
  • e

    eloew

    07/09/2020, 10:28 AM
    I am trying to use kotlin-react-router-dom, but getting browser error Error: Cannot find module 'kotlin-react-router-dom' build.gradle.kts
    implementation(npm("react-router-dom", "4.3.1"))
    implementation(npm("@jetbrains/kotlin-react-router-dom", "4.3.1-pre.91"))
    It builds but gets the error when I run. Noticed that build/js/node_modules does not have kotlin-react-router-dom I have a sample project at: https://github.com/eloew/KotlinReactRoute
    c
    t
    s
    • 4
    • 10
  • w

    willyrs

    07/10/2020, 4:12 PM
    do you feel like it’s worth to write a react app in kotlin or is it too hard to use third-party npm-packages? I have a shared module in kotlin/js and I don’t know if I should add it as dependency to a react-typescript project or go with full kotlin
    👀 1
    b
    c
    • 3
    • 9
  • s

    Siddhartha Juluru

    07/13/2020, 10:55 PM
    Does anyone know how to access static files from the processedResources folder in a Kotlin/Browser project?
    r
    • 2
    • 8
  • r

    Rob Murdock

    07/15/2020, 7:34 PM
    I’ve got some sugar functions that let me use kotlin data classes as the props type for functional components, allowing for destructuring and other data class things. Is that of interest to people? I make extensive use of it in my own codebase now, and I’m guessing others have run into similar needs / interests
    👍 1
    c
    j
    • 3
    • 6
  • e

    epabst

    08/01/2020, 4:55 AM
    I've mentioned this in a thread, but thought more people might be interested. I've successfully written tests for a React component written in Kotlin. It uses Enzyme. Example test: https://github.com/epabst/kotlin-showcase/blob/5d5129e556c8b168b0a0b838eec694664af37902/src/jsTest/kotlin/todo/ToDoScreenTest.kt. The external bindings for enzyme are here: https://github.com/epabst/kotlin-showcase/tree/5d5129e556c8b168b0a0b838eec694664af37902/src/jsTest/kotlin/enzyme.
    👍 2
    a
    r
    • 3
    • 5
  • g

    gvnavin

    08/03/2020, 2:06 PM
    Exploring this https://github.com/JetBrains/create-react-kotlin-app/#quick-overview , i created kotlin react app and opened it in intellij, the ide not detecting the kotlin dependencies. For example, i am not able to go to declaration for the kotlin libraries and other class files. Anyway to fix this ?
    c
    • 2
    • 3
  • g

    gvnavin

    08/08/2020, 6:31 AM
    Libraries Found: We have kotlin-react, kotlinx.html libraries to build front end app using kotlin. Problem: We have react for web and react native for mobile app, we are writing 2 code for building UIs. Thoughts: When kotlin can emit JS code and provide dsl for html tags to create react component, Is it possible to make them emit the react native code/components. Any thoughts on this ? Worth exploring ? Do you guys know any other information about such similar problems ?
    t
    a
    • 3
    • 9
  • b

    bnorm

    08/23/2020, 6:02 PM
    Hi! Using Kotlin 1.4 and IR? Want to try a compiler plugin that removes all the functional component boilerplate? Yes? Awesome! https://github.com/bnorm/kotlin-react-function Working on getting it published for wider consumption but for right now you can clone the project, import the
    sample
    directory, and mess around if you would like to try it out. Feel free to open issues with suggestions and any problems you find!
    👍 5
    a
    • 2
    • 3
  • b

    bnorm

    08/24/2020, 11:52 PM
    Just released version v0.1.0 of kotlin-react-function; the library above. ☝️
    j
    v
    • 3
    • 9
  • m

    mkosm

    08/26/2020, 3:52 PM
    How can I do this in Kotlin + Styled Components? Stuff like
    styledDiv
    is an extension to
    RBuilder
    , so I'm not sure how it could be used outside of `render()`: https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method
    a
    • 2
    • 2
  • j

    Joost Klitsie

    09/20/2020, 7:49 AM
    Hi all! I am trying to play some audio. If I have this audio react element:
    audio {
        attrs {
            src="sounds/time.mp3"
        }
    }
    How can I run play() on it? 🙂
    t
    • 2
    • 8
  • j

    Joost Klitsie

    09/28/2020, 3:07 PM
    Hi all! Is there any proper way to put in onClick/onTextChange things in functionalComponents? I made some extension functions to help out here:
    fun <T> CommonAttributeGroupFacade.onClick(argument: T, func: (T) -> Unit) {
        onClickFunction = useCallback(
            callback = {
                func(argument)
            },
            dependencies = arrayOf(argument)
        )
    }
    
    var CommonAttributeGroupFacade.onClick: () -> Unit
        get() = throw UnsupportedOperationException("You can't read variable onClick")
        set(newValue) {
            onClickFunction = useCallback(
                callback = {
                    newValue()
                },
                dependencies = emptyArray()
            )
        }
    
    var CommonAttributeGroupFacade.onTextChange: (String) -> Unit
        get() = throw UnsupportedOperationException("You can't read variable onChange")
        set(newValue) {
            onChangeFunction = useCallback(
                callback = { event: Event ->
                    newValue(event.target.asDynamic().value as String)
                },
                dependencies = emptyArray()
            )
        }
    The only problem I have is: if I have a list where I can add/remove items, where the list items use one of these (for example onclick), I will get (logically) errors about not having the same amount of hooks when I add/remove list items. To solve that problem, I created a useList method that wraps the list in a functional component and gets recreated on data changes:
    fun <T : BaseListItem> RBuilder.useList(
        list: List<T>,
        vararg classMap: Pair<ListStyle, String>,
        block: ListElementBuilder<UL, ListProps>.(List<T>) -> Unit
    ) {
        useCallback(
            functionalComponent<RProps> { list(classMap = *classMap, block = { block(list) }) },
            arrayOf(list)
        ).also { child(it) }
    }
    Which gives the issue of having a sluggish list during a lot of interactions (for example typing into a list element).
    a
    • 2
    • 1
Powered by Linen
Title
j

Joost Klitsie

09/28/2020, 3:07 PM
Hi all! Is there any proper way to put in onClick/onTextChange things in functionalComponents? I made some extension functions to help out here:
fun <T> CommonAttributeGroupFacade.onClick(argument: T, func: (T) -> Unit) {
    onClickFunction = useCallback(
        callback = {
            func(argument)
        },
        dependencies = arrayOf(argument)
    )
}

var CommonAttributeGroupFacade.onClick: () -> Unit
    get() = throw UnsupportedOperationException("You can't read variable onClick")
    set(newValue) {
        onClickFunction = useCallback(
            callback = {
                newValue()
            },
            dependencies = emptyArray()
        )
    }

var CommonAttributeGroupFacade.onTextChange: (String) -> Unit
    get() = throw UnsupportedOperationException("You can't read variable onChange")
    set(newValue) {
        onChangeFunction = useCallback(
            callback = { event: Event ->
                newValue(event.target.asDynamic().value as String)
            },
            dependencies = emptyArray()
        )
    }
The only problem I have is: if I have a list where I can add/remove items, where the list items use one of these (for example onclick), I will get (logically) errors about not having the same amount of hooks when I add/remove list items. To solve that problem, I created a useList method that wraps the list in a functional component and gets recreated on data changes:
fun <T : BaseListItem> RBuilder.useList(
    list: List<T>,
    vararg classMap: Pair<ListStyle, String>,
    block: ListElementBuilder<UL, ListProps>.(List<T>) -> Unit
) {
    useCallback(
        functionalComponent<RProps> { list(classMap = *classMap, block = { block(list) }) },
        arrayOf(list)
    ).also { child(it) }
}
Which gives the issue of having a sluggish list during a lot of interactions (for example typing into a list element).
a

araqnid

09/28/2020, 6:13 PM
Usually I’d have each item in the list be a separate component, and that component can then easily call useCallback just once. (Although I use React much more from just JS than Kotlin)
View count: 2