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

React renderer for your Smart Home

React renderer for your Smart Home

Presented at React Kyiv May Meetup 2018 (https://www.meetup.com/Kyiv-ReactJS-Meetup/events/249699223/)

Nowadays React.js can be used to render UIs in different environments (e.g. DOM, mobile and terminal). Recent experiments revealed a possibility to control an Arduino board with React. In my talk, I will expand the device area and show an approach to control a few wirelessly connected IoT devices using a custom React renderer.

Avatar for Alexey Zaslavsky

Alexey Zaslavsky

May 21, 2018
Tweet

Other Decks in Programming

Transcript

  1. React Fiber • React core algorithm reimplementation (v16) • Priorities

    and scheduling • Error boundaries • Asynchronous rendering • API for custom renderers 3
  2. Idea of a renderer: 1. Render user interfaces in different

    environments using the same tools 2. Declarative component-based UI 3. Learn once – use anywhere 10
  3. Common lifecycle of UIs and devices: Phase DOM Device Initial

    render createElement, appendChild, addEventListener connect, add listeners Work loop set "element.textContent" set power state, brightness Unmount removeChild, removeEventListener disconnect, remove listeners 11
  4. React workflow for a device 1. setState/forceUpdate 2. update props

    of "device" component 3. calculate changed props 4. send an update signal to the host environment 13
  5. 15

  6. Is your device smart? 1. Turn on/off 1. WiFi/Bluetooth connectivity

    2. Can be controlled remotely 3. Brightness/color can be adjusted 16
  7. What protocols are used to control? 1. Communication with Xiaomi

    Cloud (proprietary, no spec) 2. Local network – MiIO (proprietary, reverse engineered) 19
  8. References • Tiny React Renderer • Awesome list of React

    Renderer • MiHome protocol documentation 34