How to Build a React App in Kotlin Dave Ford Questions for - - PowerPoint PPT Presentation

how to build a react app in kotlin
SMART_READER_LITE
LIVE PREVIEW

How to Build a React App in Kotlin Dave Ford Questions for - - PowerPoint PPT Presentation

How to Build a React App in Kotlin Dave Ford Questions for audience Kotlin? React? create-react-app? Kotlin JS? Kotlin builders? kotlinx-html? Why Kotlin-React? Prob #1: 80% of my coding is doing this


slide-1
SLIDE 1

How to Build a React App in Kotlin

Dave Ford

slide-2
SLIDE 2

Questions for audience

  • Kotlin?
  • React?
  • create-react-app?
  • Kotlin JS?
  • Kotlin builders?
  • kotlinx-html?
slide-3
SLIDE 3

Why Kotlin-React?

slide-4
SLIDE 4

Prob #1: 80% of my coding is doing this

  • Technique #1: String building
  • Technique #2: Tree building
  • Technique #3: Templates
  • Separation of Concerns
  • Technique #4: Internal DSLs

Why Templates Are Dead

slide-5
SLIDE 5

JSX

  • JavaScript language extension
  • Adds native support for XML
  • And thus HTML
slide-6
SLIDE 6

function buttonBar({ x1, x2 }) { return <div> <button>{x1}</button> <button>{x2}</button> </div> }

JSX

slide-7
SLIDE 7

Kotlin HTML

fun buttonBar(x1: String, x2: String, x3: String){ button { +x1 } button { +x2 } button { +x3 } }

slide-8
SLIDE 8

Prob #2: Keeping things in Sync

  • Initial render + Update render
  • Updating the view when the model changes
slide-9
SLIDE 9

view = f(model)

MVC the React Way

slide-10
SLIDE 10

Updating the UI

  • Never update the UI
  • Update the model (aka state)
slide-11
SLIDE 11

Prob #3: UI Components

  • Reuse
  • Organization

Very low ceremony!!

slide-12
SLIDE 12

React with Kotlin

1. create-react-kotlin-app 2. Kotlin react wrappers 3. Kotlin's type-safe builders

slide-13
SLIDE 13

Demo

slide-14
SLIDE 14

Issues

  • node-modules/.cache/kotlin-webpack
  • attrs.style warnings
  • src slash issue
slide-15
SLIDE 15

Summary

npm install -g create-react-kotlin-app create-react-kotlin-app my-app Function Components Class Components

slide-16
SLIDE 16

https://twitter.com/@daveford Dave Ford dford@smart-soft.com https://medium.com/@daveford

www.smart-soft.com