Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin with JavaScript & React: A Reality

Kotlin with JavaScript & React: A Reality

Adora Nwodo

July 06, 2019
Tweet

More Decks by Adora Nwodo

Other Decks in Programming

Transcript

  1. Hi, I’m Adora Software Engineer Creator, adorahack.com Co-organizer GDG Ajah,

    Unstack, Android Ngr Twitter: @theadoranwodo YouTube: adorahack
  2. You’re not a fan of comparisons in Javascript '' ==

    false 0 == false 0 === false null === undefined null == undefined null >= 0
  3. Interoperability index.js function getToken(){ // do some stuff here //

    return a token string } Main.kt val TOKEN = js("getToken()") as String
  4. const Message = ({ message}) => { if (message )

    { return ( <div>Hey, {message}</div> ); } return null } Functional Components - Message.js
  5. fun RBuilder.alert(message: String = "") = if (message.isNotEmpty()) { div{

    + “Hey, $message” } } else { empty } Functional Components - Message.kt
  6. interface WelcomeProps: RProps { var name: String } class Welcome:

    RComponent<WelcomeProps, RState>() { override fun RBuilder.render() { div { +"Hello, ${props.name}" } } } fun RBuilder.welcome(name: String = "John") = child(Welcome::class) { attrs.name = name } Class Components (Welcome.kt) Code snippet from https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-react
  7. kotlin-css & kotlin-styled DSL for creating stylesheets in Kotlin. npm

    i @jetbrains/kotlin-css npm i @jetbrains/kotlin-css-js npm i @jetbrains/kotlin-styled
  8. • Introduction to Kotlin • Why Kotlin for JavaScript •

    Kotlin in React • Existing Kotlin JS wrappers Summary