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

Create React Kotlin app

Create React Kotlin app

Hands on session at #KotlinEverywhere event by GDG-Makurdi, Nigeria. We walked through creating our first react app using Kotlin. Very beginners friendly.

Avatar for Pius Aboyi

Pius Aboyi

July 06, 2019

More Decks by Pius Aboyi

Other Decks in Technology

Transcript

  1. Before we start the Engine • Built a website before?

    • React? • Kotlin? • Kotlin JS?
  2. Templates • String Building • DOM (Append Nodes) • Templates

    (Static parts and little parts that change) Example: Angular Template <li *ngFor="let hero of heroes"> <span class="badge">{{hero.id}}</span> {{hero.name}} </li>
  3. JSX 1. function buttonBar({x1, x2}) { 2. return <div> 3.

    <button>{x1}</button> 4. <button>{x2}</button> 5. </div> 6. }
  4. Hello World React Kotlin app fun main(args: Array<String>) { val

    rootDiv = document.getElementById("root") render(rootDiv) { h1 { + "Hello World!" } } } File: gdg-makurdi/src/index/index.kt
  5. div { h1 { + "Blackjack" } div { div

    { div { b { + "Player Hand"} } div { b { + "cards go here" } } div { b { + "12 cards" } } } } } More Tags
  6. div { h1 { + "Blackjack" } div { attrs.title

    = "Hands" //shows title when you hover on this div attrs.style = kotlinext.js.js { display = "flex" //keeps hands side-by-side } handUi() } } Add props to Tag
  7. fun RBuilder.handUi(hName: String, gPoints: String) { div { div {

    b { +"$hName Hand" } } div { b { +"cards go here" } } div { b { +"$gPoints cards" } } } } Reusable UI Components File: gdg-makurdi/src/bj/handUi.kt