All Projects → fluidsonic → fluid-react

fluidsonic / fluid-react

Licence: Apache-2.0 license
Highly experimental Kotlin wrapper for React

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to fluid-react

kmdc
Kompose wrappers for material-components-web
Stars: ✭ 66 (+450%)
Mutual labels:  kotlin-js, kotlin-js-wrappers
npm-publish
Gradle plugin for NPM package publishing. Allows for arbitrary publishing as well as seamless integration with Kotlin JS/MPP plugins.
Stars: ✭ 66 (+450%)
Mutual labels:  kotlin-js
intro-kotlin-mutliplatform
Kotlin Multiplatform project (MPP), JVM and JS
Stars: ✭ 21 (+75%)
Mutual labels:  kotlin-js
kotlin-telegram
Repository with information about Kotlin chats on Telegram.
Stars: ✭ 21 (+75%)
Mutual labels:  kotlin-js
KotlinReactNativeMpp
A ReactNative App written with Kotlin JS
Stars: ✭ 26 (+116.67%)
Mutual labels:  kotlin-js
kotlin-js-wrappers
Kotlin JS wrappers for popular JavaScript libraries
Stars: ✭ 48 (+300%)
Mutual labels:  kotlin-js-wrappers
thelema-engine
Thelema - 3D graphics engine, written in Kotlin. Based on sources of libGDX.
Stars: ✭ 51 (+325%)
Mutual labels:  kotlin-js
mqtt
Kotlin cross-platform, coroutine based, reflectionless MQTT 3.1.1 & 5.0 client & server
Stars: ✭ 31 (+158.33%)
Mutual labels:  kotlin-js
Sheasy
This an Android App that helps you share/manage your files on your Android Device through a WebInterface in the Browser - Built with Ktor and Kotlin-React
Stars: ✭ 34 (+183.33%)
Mutual labels:  kotlin-js
kotlin-js-D3js-example
A simple example of a D3 JavaScript program in Kotlin
Stars: ✭ 13 (+8.33%)
Mutual labels:  kotlin-js
KotlinMultiplatformAndoridParcelize
Use the Parcelize Annotation of the Kotlin Android Extensions in Kotin Multiplatform projects
Stars: ✭ 16 (+33.33%)
Mutual labels:  kotlin-js
patternfly-fritz2
Pure Kotlin implementation of PatternFly
Stars: ✭ 31 (+158.33%)
Mutual labels:  kotlin-js
kfsm
Finite State Machine in Kotlin
Stars: ✭ 76 (+533.33%)
Mutual labels:  kotlin-js
Maily-Form
Forms on any website
Stars: ✭ 29 (+141.67%)
Mutual labels:  kotlin-js
tmdb-api
This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.
Stars: ✭ 31 (+158.33%)
Mutual labels:  kotlin-js
three-kt-wrapper
Kotlin wrappers for Three.js
Stars: ✭ 46 (+283.33%)
Mutual labels:  kotlin-js
Lavalink.kt
Coroutine based client for Lavalink (Kotlin and Java)
Stars: ✭ 31 (+158.33%)
Mutual labels:  kotlin-js
kotlin-multiplatform-example
A Kotlin multiplatform example app that targets Android, ReactJS, iOS, JavaFx, and Spring Boot
Stars: ✭ 115 (+858.33%)
Mutual labels:  kotlin-js
vjson
A simple JSON parser and (de)serializer library for java/kotlin and kotlin-native/js. Also provides a strongly-typed language: vjson-lang.
Stars: ✭ 31 (+158.33%)
Mutual labels:  kotlin-js
ktcc
C Compiler that generates readable Kotlin and C# - Written in Kotlin + Small web-based Editor with autocompletion
Stars: ✭ 54 (+350%)
Mutual labels:  kotlin-js

fluid-react

Maven Central Kotlin React #fluid-libraries Slack Channel

Kotlin/JS wrapper for React, React Router and react-helmet-async.

  • Similar to kotlin-react.
  • Nicer and consistent API. Easier to use.
  • Not multiplatform. Optimized for Kotlin/JS instead.
  • Lower size and performance overhead.
  • More type safety, esp. around hooks.
  • With new Concurrent Mode in mind, thus depending on experimental React releases.
  • Props allow class instead of just external interface.
  • Updates of local properties delegated with by useState(…) are reflected immediately.
  • Support for coroutines with CoroutineScope(…) { … }, useCoroutineScope() and useFlow(…).
  • @DslMarker colors.
  • Experimental and IR compiler only. Relies on compiler-internal behavior until KT-10468 is solved.
  • Contributions welcome 😃
  • Kotlin/JS-optimized CSS library with nice API in the works.

Notable differences in behavior

  • Components created with react.component() are memoized by default unless they have children (react.componentWithChildren()).
  • Memoization of components created with react.component() or added by RComponent.memo() use equals() to compare Props. You must ensure that your props implement equals() in order to benefit from memoization.
  • Hook dependencies use equals() instead of ===. They don't need to be an Array nor is the same amount of dependencies needed for each render.
  • Router routes are exact, strict and sensitive by default.

Installation

build.gradle.kts:

dependencies {
    implementation("io.fluidsonic.react:fluid-react-dom:0.12.0") // basis module

    implementation("io.fluidsonic.react:fluid-react-coroutines:0.12.0") // optional coroutine support
    implementation("io.fluidsonic.react:fluid-react-helmet:0.12.0")     // optional dynamic metadata (react-helmet-async)
    implementation("io.fluidsonic.react:fluid-react-router-dom:0.12.0") // optional routing (react-router)
}

Example

import io.fluidsonic.react.*
import kotlinx.browser.*

fun main() {
    val body = checkNotNull(document.body)
    val container = document.createElement("div").also(body::appendChild)

    react.createRoot(container).render {
        +"Hello world"

        EmojiContainer(EmojiContainerProps("😍")) { strong { +"cool" } }
    }
}

val EmojiContainer by react.componentWithChildren { props: EmojiContainerProps, children ->
    var count by useState(3)

    useEffect(count) {
        val timerId = window.setTimeout({ count += 1 }, 2000)

        cleanup { window.clearTimeout(timerId) }
    }

    h1 { +"Your emoji, $count times 🎉" }
    button {
        attrs.onClick = { count += 1 }
        +"Add one"
    }
    ol {
        repeat(count) {
            li {
                +props.emoji
                +" "
                children()
            }
        }
    }
}

class EmojiContainerProps(val emoji: String)

Also check out the playground and run it from IntelliJ IDEA.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].