Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Kotlin with JavaScript & React: A Reality
Search
Adora Nwodo
July 06, 2019
Programming
240
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin with JavaScript & React: A Reality
Adora Nwodo
July 06, 2019
Transcript
28 slides
KOTLIN WITH JAVASCRIPT & REACT: A REALITY
Hi, I’m Adora Software Engineer Creator, adorahack.com Co-organizer GDG Ajah,
Unstack, Android Ngr Twitter: @theadoranwodo YouTube: adorahack
KOTLIN ?
Kotlin is a cross-platform, statically typed, general-purpose programming language with
type inference.
WHY KOTLIN FOR JAVASCRIPT?
You’re not a fan of comparisons in Javascript '' ==
false 0 == false 0 === false null === undefined null == undefined null >= 0
Interoperability index.js function getToken(){ // do some stuff here //
return a token string } Main.kt val TOKEN = js("getToken()") as String
Kotlin is modern & easy to learn.
Share code between platforms
KOTLIN & REACT
Create React Kotlin App. npm install -g create-react-kotlin-app Kotlin React
Wrapper. npm i @jetbrains/kotlin-react
Lambdas are used in place of JSX when doing React
with Kotlin
const Message = ({ message}) => { if (message )
{ return ( <div>Hey, {message}</div> ); } return null } Functional Components - Message.js
fun RBuilder.alert(message: String = "") = if (message.isNotEmpty()) { div{
+ “Hey, $message” } } else { empty } Functional Components - Message.kt
• RComponent • RBuilder • RState • RProps • RActions
• rEnhancer Some things to remember
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
Reusing Components Code snippet from https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-react fun RBuilder.welcome(name: String =
"John") = child(Welcome::class) { attrs.name = name }
OTHER KOTLIN WEB WRAPPERS
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
kotlin-mocha If you want to test, use this guy. npm
i @jetbrains/kotlin-mocha
kotlin-react-dom Kotlin wrapper for the React DOM library. npm i
@jetbrains/kotlin-react-dom
kotlin-react-redux Kotlin wrapper for the React Redux library. npm i
@jetbrains/kotlin-react-redux
kotlin-react-router-dom Kotlin wrapper for the React Router DOM library. npm
i @jetbrains/kotlin-react-router-dom
kotlin-redux Kotlin wrapper for the Redux library. npm i @jetbrains/kotlin-redux
• Introduction to Kotlin • Why Kotlin for JavaScript •
Kotlin in React • Existing Kotlin JS wrappers Summary
• https://kotlinlang.org/docs/reference/js-overview.html • https://github.com/JetBrains/kotlin-wrappers • https://github.com/JetBrains/create-react-kotlin-app • https://adorahack.com Helpful resources
Build for the web however you like!
THANKS! Website: adoranwodo.com Blog: adorahack.com Twitter: @adoranwodo
More Decks by Adora Nwodo
See All by Adora Nwodo
Harnessing the Power of AI in Open-Source Cloud Engineering
adoranwodo
2
360
Getting Started With Data Structures
adoranwodo
1
510
StereoKit: The Open Source SDK for VR/MR
adoranwodo
0
240
Accessibility in the context of Mixed Reality
adoranwodo
0
120
Skills to Excel in Cloud Engineering
adoranwodo
0
500
The Opportunities In The Decade Of Mixed Realities
adoranwodo
0
140
7 Habits of Highly Effective Engineering Teams
adoranwodo
0
260
Designing secure cloud applications
adoranwodo
0
250
Building a sustainable personal brand
adoranwodo
0
200
Other Decks in Programming
See All in Programming
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
690
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
200
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
720
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
220
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
240
LLM 101
dalinaum
0
510
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
580
SODA - FACT BOOK(JP)
sodainc
1
40k
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
310
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1k
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
110
Featured
See All Featured
Side Projects
sachag
456
43k
sira's awesome portfolio website redesign presentation
elsirapls
0
510
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
530
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
380
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
60k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
620
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.4k
WENDY [Excerpt]
tessaabrams
15
41k
Code Review Best Practice
trishagee
74
20k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k