Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
megamaddu committed Jan 24, 2019
1 parent 542decc commit 24ea272
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,37 @@

This package implements an opinionated set of bindings over [React](https://reactjs.org), optimizing for correctness and simplifying basic use cases.

_A note about React hooks: Hooks are arriving in stable React soon. The API presented here is the more traditional `setState`+lifecycles style React's had for a long time. If you'd like to experiment with the hooks API in react-basic, have a look at [react-basic-hooks](https://github.com/spicydonuts/purescript-react-basic-hooks). It can be installed and used along side this library, but don't forget it's a preview release!_

## 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](https://reasonml.github.io/reason-react/).
- Both `setState` and an action/update pattern for local component state, inspired by [ReasonReact](https://reasonml.github.io/reason-react/).
- 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:

```sh
bower install purescript-react-basic
bower install --save purescript-react-basic
```

Or clone/fork the [starter project](https://github.com/lumihq/react-basic-starter).

See [the documentation](https://pursuit.purescript.org/packages/purescript-react-basic/docs/React.Basic) for a detailed overview, or take a look at one of the examples:
See [the documentation](https://pursuit.purescript.org/packages/purescript-react-basic/docs/React.Basic) for an overview of the API or take a look at these examples:

- [A Counter](./examples/counter/src/Counter.purs)
- [A counter](./examples/counter/src/Counter.purs)
- [A controlled input](./examples/controlled-input/src/ControlledInput.purs)
- [Components](./examples/component/src/ToggleButton.purs) in [components](./examples/component/src/Container.purs)
- [Using action/update](./examples/actions/src/Actions.purs)

## Migrating from v7 to v8

v8 removes the required `update` function from the component spec and replaces `send self Action` with the `self.setState` API. Existing components using `update` can create a `send` function using the `runUpdate` function added in v8. See [the actions example](./examples/actions/src/Actions.purs) for an example of this. Alternatively, [this comment](https://github.com/lumihq/purescript-react-basic/pull/73#issuecomment-456486249) shows a few other possible upgrade paths.

## Migrating from v2 or v3
## Migrating from v2/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.
19 changes: 12 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"build": "pulp build && npm run build:examples",
"build:examples": "PATH=`echo $PATH | sed -e 's/:\\.\\/node_modules\\/\\.bin//'` find examples -maxdepth 2 -type f -iname makefile -execdir make \\;",
"audit:examples": "PATH=`echo $PATH | sed -e 's/:\\.\\/node_modules\\/\\.bin//'` find examples -maxdepth 2 -type f -iname makefile -execdir npm audit fix \\;",
"test": "npm run build"
},
"repository": {
Expand Down

0 comments on commit 24ea272

Please sign in to comment.