WhoBuilt

Reasonable React Native

Sep 14, 2018· 33 min· 261 views·Watch on YouTube

Speaker

Ken Wheeler, director of open source at Seattle-based consultancy Formidable, explains Reason and ReasonReact for building React Native apps at a Callstack event.

Why consider Reason

Wheeler argues that building complex applications in JavaScript can feel unreasonable, and introduces Reason as a typed syntax and toolchain for OCaml that feels familiar to JavaScript developers. He highlights static types, type inference, native compilation, and the ability to adopt Reason incrementally alongside existing JavaScript.

Reason language fundamentals

Wheeler walks through familiar primitives, block-scoped let bindings, and Reason’s module system, where each file acts as a module and names are accessed with dot notation. He also covers function shorthand, labeled arguments, records, variants, and pattern matching, including variants for idle, loading, and error states.

Compiling to JavaScript and using ReasonReact

BuckleScript compiles Reason and OCaml to readable JavaScript and provides interop through typed external declarations. Wheeler then explains ReasonReact components, props, text conversion, and state updates, which use updater functions returning a new state or a no-update result.

React Native bindings and styles

Wheeler recommends the community’s BSReactNative bindings so developers can use pre-typed React Native APIs. The bindings represent many style values as language-level enums, enabling completion and rejecting unsupported values such as an invalid style property.

A shipped app and project setup

Wheeler describes building the Seattle JS conference React Native app in Reason over two weeks and says it included a modal animation that opened from an item’s position. He outlines setup with a React Native app, bs-platform, bs-react-native, reason-react, a BuckleScript config, and build and watch scripts; the JavaScript app entry point imports the compiled Reason component.

Takeaways

  • Reason can be introduced incrementally into JavaScript projects, according to Wheeler.
  • Variants and pattern matching can make loading, idle, and error states explicit.
  • Typed React Native bindings can catch invalid style values while coding.
  • A ReasonReact project needs a JavaScript entry point that connects to the compiled Reason component.
  • Wheeler’s conference app shows one developer using Reason for a nontrivial React Native project.

Mentioned in this talk

Search inside this talk

What was claimed 9

Related talks