Kotlin Wrappers
This repository hosts a number of Kotlin wrappers for popular JavaScript libraries, such as React, Mocha, and styled-components.
To learn more please refer to the READMEs of individual modules:
- kotlin-css,
- kotlin-extensions,
- kotlin-mocha,
- kotlin-react,
- kotlin-react-dom,
- kotlin-react-redux,
- kotlin-react-router-dom,
- kotlin-react-table,
- kotlin-redux,
- kotlin-styled.
All wrappers are available on npm: npm install @jetbrains/<wrapper name>
Artifacts installable using Maven and Gradle are published to Bintray and JCenter.
All packages require JDK 8 to be installed.
Examples
-
A port of "Thinking in React" example
-
An example of using axios to fetch remote data. It also demonstrates how to add typings for an external library.
-
An example of using Quill that shows how to use an external React component.
-
An example of using react-router-dom that shows how to use react-route-dom with hooks API.
-
Building Web Applications with React and Kotlin/JS, a tutorial by JetBrains.
-
A full-stack demo application written in Kotlin for JetBrains Night Moscow 2019.
-
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
orRState
should be marked asexternal
interface. Otherwise, you will getUncaught 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 asTypeError: 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.