Git Product home page Git Product logo

kotlin-wrappers's Introduction

JetBrains team project CI Maven Central Kotlin Slack channel

Kotlin Wrappers

This repository hosts a number of Kotlin wrappers for popular JavaScript libraries.

To learn more please refer to the READMEs of individual modules.

README Version
kotlin-css Maven Central
kotlin-extensions Maven Central
kotlin-react Maven Central
kotlin-react-dom Maven Central
kotlin-react-redux Maven Central
kotlin-react-router-dom Maven Central
kotlin-react-query Maven Central
kotlin-react-table Maven Central
kotlin-redux Maven Central
kotlin-ring-ui Maven Central
kotlin-styled Maven Central
kotlin-styled-next Maven Central
kotlin-wrappers-bom Maven Central

Artifacts are published to Maven Central, see the corresponding README files for package coordinates.

Important: versions up to pre.156 were published under org.jetbrains group ID to kotlin.jetbrains.space, newer versions are being published to Maven Central and the new group ID is org.jetbrains.kotlin-wrappers. Upon changing the group ID the version number was bumped to pre.200 to signal the breaking change.

All packages require JDK 8 to be installed.

Using In Your Projects

Use the "Kotlin Wrappers BOM" which helps to ensure consistency between the modules and allows you not to think about version compatibility.

Just declare kotlin-wrappers-bom and specify the modules you need:

val kotlinWrappersVersion = "0.0.1-pre.231-kotlin-1.5.21"

dependencies {
    implementation(enforcedPlatform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"))
    implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
    implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
    implementation("org.jetbrains.kotlin-wrappers:kotlin-react-table")
    implementation("org.jetbrains.kotlin-wrappers:kotlin-styled")
    // other wrappers
}

Or use a helper function:

fun kotlinw(target: String): String =
    "org.jetbrains.kotlin-wrappers:kotlin-$target"

val kotlinWrappersVersion = "0.0.1-pre.231-kotlin-1.5.21"

dependencies {
    implementation(enforcedPlatform(kotlinw("wrappers-bom:${kotlinWrappersVersion}")))
    implementation(kotlinw("react"))
    implementation(kotlinw("react-dom"))
    implementation(kotlinw("react-table"))
    implementation(kotlinw("styled"))
    // other wrappers
}

Make sure that you have mavenCentral() in the list of repositories.

Examples

  1. To-do list example

  2. Tic-Tac-Toe example

  3. A port of "Thinking in React" example

  4. An example of using axios to fetch remote data. It also demonstrates how to add typings for an external library.

  5. An example of using Quill that shows how to use an external React component.

  6. An example of using react-router-dom that shows how to use react-route-dom with hooks API.

  7. Building Web Applications with React and Kotlin/JS, a tutorial by JetBrains.

  8. A full-stack demo application written in Kotlin for JetBrains Night Moscow 2019.

  9. An example of using react-table that shows how to use react-table with hooks API.

Follow these examples to learn how to start developing your React apps with Kotlin. Good luck and have fun! You also can clone my-kotlin-react-sample to see the result directly.

Experimental IR Backend

Please note that React wrappers in particular heavily relied on specific characteristics of the default backend, which might make your current code incompatible with the new IR backend.

React error: "X not a function" in production mode:

  • Every interface implementing RProps or RState should be marked as external interface. Otherwise, you will get Uncaught ClassCastException. If you’re implementing these interfaces via a class, you can mark it as @JsExport — however, we suggest evaluating if you could use an external interface instead.
  • Every component extending RComponent must be marked with @JsExport. Otherwise, you might run into issues such as TypeError: l.render is not a function (react-dom.production.min.js:182)
  • https://youtrack.jetbrains.com/issue/KT-42427, https://youtrack.jetbrains.com/issue/KT-39506

Contributing

Contributions to this project are welcome! Please see the open issues or chat with us on the #react channel in our Slack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.