/purescript-react-basic

An opinionated set of bindings to the React library, optimizing for the most basic use cases

Primary LanguagePureScriptApache License 2.0Apache-2.0

purescript-react-basic

Build Status

This package implements an opinionated set of bindings over React, optimizing for correctness and simplifying basic use cases.

Features

  • All React DOM elements and attributes are supported (soon, events are a work in progress).
  • An intuitive API for specifying props - simple records, no arrays of key value pairs.
  • Attributes are optional, but type-checked. It is a type error to specify href as an integer, for example.
  • An action/update pattern for local component state, inspired by ReasonReact.
  • React lifecycles are available, but not in your way when you don't need them.
  • Typeclasses, like Eq props, can be used in component definitions.

Getting Started

You can install this package using Bower:

bower install purescript-react-basic

Or clone/fork the starter project.

See the documentation for a detailed overview, or take a look at one of the examples:

Migrating from v2 or v3

React.Basic.Compat is a new (but deprecated) module. It matches most of the old API and types (except setStateThen and isFirstMount) to make upgrading easier and more gradual. You can find ^import\sReact\.Basic\b and replace with import React.Basic.Compat, upgrade the package version, and proceed from there one component at a time (or only new components). See the documentation link above for more info on the new API.