Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reason-react

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reason-react - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

.merlin

6

FUTURE.md

@@ -10,7 +10,4 @@ Like HISTORY.md, but for planned future versions and subject to change. The vocabulary here uses the past tense, to pretend that the versions are already published.

# 0.2.1
# 0.3.0 (breaking)
- `enqueue`. Best thing ever.
- Secret (feature-that-must-not-be-named)
- remove create-react-class
- Set lifecycles to null when they do nothing. React skips over lifecycles that are set to null, we currently have wrappers around all of them, so things like didMount are enqueued for *every* component.

@@ -20,1 +17,2 @@ - `ReactDOMRe.createElement` (usually used through the JSX `<div> foo </div>`) has a new implementation that fixes an inadvertent children key warning in the previous version.

- better modeling for `stateless` and `retainedProps` from `unit` to something else
- expose `ReasonReact.publicComponentSpec state retainedProps action` for less cryptic component type annotation.

@@ -0,1 +1,58 @@

# 0.2.4
**Major update**, but again with **no** breaking changes, and _again_ with a convenience [migration script](https://github.com/reasonml/reason-react/blob/master/migrateFrom02xTo024.js)! =)
The big change in this release is the deprecation of `statefulComponent` and `statefulComponentWithRetainedProps`.
## Prerequisites
**Please first read the [blog post](https://reasonml.github.io/reason-react/reason-react/docs/blog.html#reducers-are-here)**.
**After** reading this migration guide, use the migratio script (or not) like so: `node node_modules/reason-react/migrateFrom02xTo024.js myReasonFile.re`.
## Migrate From StatefulComponent to ReducerComponent
There's no more need for `ReasonReact.statefulComponent`. Every state change is now controlled through a dedicated, centralized, react-fiber-ready, component-local mechanism called "reducer" (aka, the hype word for "state machine").
[Reason-react-example](https://github.com/reasonml-community/reason-react-example) is updated too. Go check the examples afterward!
In short:
- Replace all `ReasonReact.statefulComponent` with `ReasonReact.reducerComponent`.
- Replace e.g. `self.update handleClick` (where `handleClick` is `fun self => ReasonReact.Update {...self.state, foo: bar}`) with `self.reduce (fun _ => Click)`. `Click` is just a variant constructor you've defined. Let's call it "action".
- Add a `reducer` function to the body of your `...component` spread:
```reason
reducer: fun action state =>
switch action {
| Click => ReasonReact.Update {...state, foo: bar}
}
```
We've also exposed new `ReasonReact.SideEffects` (aka `ReasonReact.NoUpdate`, with side-effect) and `ReasonReact.UpdateWithSideEffects` (`ReasonReact.Update` + side-effect).
The relevant section on actions, reducers and the new update additions are [in the main docs](https://reasonml.github.io/reason-react/docs/index.html#reason-react-component-creation-state-actions-reducer).
## InstanceVars/React Ref Usage Changed
Before, we used to recommend using `ReasonReact.SilentUpdate` to deal with ReactJS' instance variables pattern (e.g. attaching properties onto the component class itself, like timer IDs, refs, etc.). Now we've moved to using a Reason `ref` cell (not the React ref, the [mutative Reason `ref`](https://reasonml.github.io/guide/language/imperative-loops)). See the updated [instance variables section](https://reasonml.github.io/reason-react/#reason-react-component-creation-instance-variables).
The new recommendation also solves a corner-case bug with assigning more than one refs in the render.
## LifeCycle
The future ReactJS Fiber in ReasonReact won't work well with lifecycle events that return the new state (aka `ReasonReact.Update {...state, foo: bar}`). Please return `ReasonReact.NoUpdate`. If you really need to trigger a state change, before the return, use a `self.reduce (fun () => Bar) ()`, aka immediately apply a reduce.
## Miscellaneous Changes
- Add `defaultChecked`, `loop` and others to DOM attribute (#29, #37, #44, #50).
- Fix `cloneElement` binding (#49).
- Fix stateless components's `willReceiveProps`'s return value. It's now `unit` again.
- Fix wrong version of `retainedProps` in `willReceiveProps`.
- Remove the dependency on `create-react-class`. Now we're back to being dependency-free!
- Bump react/react-dom to 16.
- React/react-dom are now dependencies, rather than peerDependencies. This follows the Reason/BS idiom of making the bound library an implementation detail. NPM/Yarn will still dedupe multiple versions of react/react-dom correctly; no worries about that.
Enjoy!
# 0.2.1

@@ -7,5 +64,5 @@

We've given folks a bit of breathing room in terms of breaking changes; now we're shipping another one, this time with a small migration script. **After installing reason-react**, use `node node_modules/reason-react/migrateFrom015To020.js myReasonFile.re`
We've given folks a bit of breathing room in terms of breaking changes; now we're shipping another one, this time with a small migration script. **After installing reason-react**, use `node node_modules/reason-react/oldScriptCarefulMigrateFrom015To020.js myReasonFile.re`
- Instead of `fun state self => ...`, we've now rolled `state` into `self`, and now, you have `fun {state, self} => ...`. Feel free to destructure and get whatever you need!
- Instead of `fun state self => ...`, we've now rolled `state` into `self`, and now, you have `fun {state, handle} => ...`. The whole record is `self`. Feel free to destructure and get whatever you need!
- `self` now contains a new prop, `retainedProps`. This is a new (non-breaking) feature that solves the previous slightly inconvenient way of forwarding props to state, as described in the old API's lifecycle methods. Now there's a dedicated API for it! The docs describes this in detail.

@@ -157,3 +214,3 @@

# 0.1.3
DOM ref is now typed as `Js.null Dom.element`, instead of just `Dom.element` (https://github.com/reasonml/reason-react/commit/6f2a75b). Trivial migration: https://github.com/chenglou/reason-react-example/commit/b44587a
DOM ref is now typed as `Js.null Dom.element`, instead of just `Dom.element` (https://github.com/reasonml/reason-react/commit/6f2a75b). Trivial migration: https://github.com/reasonml-community/reason-react-example/commit/b44587a

@@ -160,0 +217,0 @@ # 0.1.2

{
"name": "reason-react",
"version": "0.2.3",
"version": "0.2.4",
"description": "",
"main": "index.js",
"scripts": {
"test": "exit 0",
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world"
"clean": "bsb -clean-world",
"test": "exit 0"
},
"keywords": [],
"author": "",
"license": "ISC",
"license": "MIT",
"repository": {

@@ -18,12 +19,9 @@ "type": "git",

},
"dependencies": {
"create-react-class": "^15.0.0"
},
"devDependencies": {
"bs-platform": "^1.8.0"
"bs-platform": "^1.8.2"
},
"peerDependencies": {
"react": "^15.0.0",
"react-dom": "^15.0.0"
"dependencies": {
"react": ">=15.0.0",
"react-dom": ">=15.0.0"
}
}

@@ -12,3 +12,3 @@ # ReasonReact

## Usage
See https://github.com/chenglou/reason-react-example
See https://github.com/reasonml-community/reason-react-example

@@ -29,1 +29,3 @@ ## Documentation

Then add some files somewhere (don't forget to change `bsconfig.json`, if needed).
See the README inside `src` for more info!

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc