Skip to content

Updates for React.Basic 15 #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .circleci/config.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dist: trusty
sudo: required
language: node_js
node_js:
- node
- "lts/*"

cache: npm

install:
- npm ci
- npx bower i

script:
- npx pulp build
27 changes: 0 additions & 27 deletions Makefile

This file was deleted.

35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# react-basic-hooks [![CircleCI](https://circleci.com/gh/spicydonuts/purescript-react-basic-hooks.svg?style=svg)](https://circleci.com/gh/spicydonuts/purescript-react-basic-hooks)
# react-basic-hooks [![Build Status](https://travis-ci.com/spicydonuts/purescript-react-basic-hooks.svg?branch=main)](https://travis-ci.com/spicydonuts/purescript-react-basic-hooks)

`react-basic-hooks` adds React hook support to [react-basic](https://github.com/lumihq/purescript-react-basic)!
`react-basic-hooks` is a React hook API for [react-basic](https://github.com/lumihq/purescript-react-basic). For more info and guides, see the React Basic [docs](https://react-basic-starter.github.io/)! (work in progress)

_Note:_ This API relies on recent React versions (>= 16.8.0).
For more info on hooks, see [React's documentation](https://reactjs.org/docs/hooks-intro.html).
_Note:_ This API relies on React `>=16.8.0`. For more info on hooks, see [React's documentation](https://reactjs.org/docs/hooks-intro.html).

I recommend using PureScript's "qualified do" syntax while using this library (it's used in the examples, the `React.do` bits).
It became available in the `0.12.2` compiler release.
Expand All @@ -15,28 +14,16 @@ If we prefer this API over the existing react-basic API, we may eventually repla
## Example

```purs
mkCounter :: Effect (ReactComponent {})
mkCounter :: Component Int
mkCounter = do
component "Counter" \props -> React.do
counter /\ setCounter <- useState 0
component "Counter" \initialValue -> React.do
counter /\ setCounter <- useState initialValue

pure
$ R.button
{ onClick: handler_ do
setCounter (_ + 1)
, children:
[ R.text $ "Increment: " <> show counter ]
}
{ onClick: handler_ do
setCounter (_ + 1)
, children:
[ R.text $ "Increment: " <> show counter ]
}
```

More examples:

- [Counter with an effect](./examples/counter/src/Example.purs)
- [Reducer/action-style](./examples/reducer/src/Example.purs)
- [Controlled inputs](./examples/controlled-input/src/Example.purs)
- Components: [Parent](./examples/component/src/Example.purs) and [Child](./examples/component/src/ToggleButton.purs)
- [Refs to DOM nodes](./examples/refs/src/Example.purs) (and extracting hook logic from a component for reuse)
- [A Todo App](./examples/todo-app/src/Example.purs) (components, inputs, state)
- [Context](./examples/context/src/Example.purs) (creating and consuming React context)
- [Aff](./examples/aff/src/Example.purs) (rendering async data, using error boundaries)
- [Suspense](./examples/suspense/src/Example.purs) (experimental, React Suspense demo -- similar to the Aff example, but the loading state is managed by the parent instead of the detail rendering component)
19 changes: 13 additions & 6 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
},
"dependencies": {
"purescript-prelude": "^4.1.0",
"purescript-console": "^4.2.0",
"purescript-effect": "^2.0.0",
"purescript-react-basic": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
"purescript-indexed-monad": "^1.0.0",
"purescript-effect": "^2.0.1",
"purescript-aff": "^5.1.2",
"purescript-newtype": "^3.0.0",
"purescript-maybe": "^4.0.1",
"purescript-numbers": "^7.0.0",
"purescript-either": "^4.1.1",
"purescript-type-equality": "^3.0.0",
"purescript-datetime": "^4.1.1",
"purescript-web-html": "^2.3.0",
"purescript-aff-promise": "^2.1.0",
"purescript-unsafe-reference": "^3.0.1",
"purescript-aff": "^5.1.1",
"purescript-aff-promise": "^2.1.0"
"purescript-indexed-monad": "^1.2.0",
"purescript-react-basic": "^15.0.0",
"purescript-unsafe-coerce": "^4.0.0"
},
"devDependencies": {
"purescript-psci-support": "^4.0.0"
Expand Down
11 changes: 0 additions & 11 deletions examples/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions examples/aff/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions examples/aff/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions examples/aff/html/index.html

This file was deleted.

142 changes: 0 additions & 142 deletions examples/aff/src/Example.purs

This file was deleted.

21 changes: 0 additions & 21 deletions examples/aff/src/Main.purs

This file was deleted.

4 changes: 0 additions & 4 deletions examples/component/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions examples/component/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions examples/component/html/index.html

This file was deleted.

Loading