New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

reason-react-update

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reason-react-update - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

examples/LegacyUsage.re

7

HISTORY.md

@@ -0,1 +1,8 @@

## 1.0.0
Features:
- Add `ReactUpdateLegacy` for uncancellable effects, easing the migration process if copy pasting from record API reducers (c4ccec5)
- Add `useReducerWithMapState` API to enable lazy state init (19eee9a)
## 0.1.1

@@ -2,0 +9,0 @@

4

package.json
{
"name": "reason-react-update",
"version": "0.1.1",
"version": "1.0.0",
"scripts": {

@@ -26,3 +26,3 @@ "build": "bsb -make-world",

"devDependencies": {
"bs-platform": "^5.0.1",
"bs-platform": "^5.0.3",
"react": "^16.8.0",

@@ -29,0 +29,0 @@ "react-dom": "^16.8.0",

@@ -34,3 +34,3 @@ # reason-react-update

| Increment => Update(state + 1)
| Decrement => Update(state + 1)
| Decrement => Update(state - 1)
}

@@ -46,2 +46,34 @@ );

### Lazy initialisation
## ReactUpdate.useReducer
If you'd rather initialize state lazily (if there's so computation you don't want executed at every render for instance), use `useReducerWithMapState` where the first argument is a function taking `unit` and returning the initial state.
```reason
type state = int;
type action =
| Increment
| Decrement;
[@react.component]
let make = () => {
let (state, send) =
ReactUpdate.useReducerWithMapState(
() => 0,
(action, state) =>
switch (action) {
| Increment => Update(state + 1)
| Decrement => Update(state + 1)
}
);
<div>
{state->Js.String.make->React.string}
<button onClick={_ => send(Decrement)}> "-"->React.string </button>
<button onClick={_ => send(Increment)}> "+"->React.string </button>
</div>;
};
```
### Cancelling a side effect

@@ -66,1 +98,3 @@

```
If you want to copy/paste old reducers that don't support cancellation, you can use `ReactUpdateLegacy` instead in place of `ReactUpdate`. Its `SideEffects` and `UpdateWithSideEffects` functions accept functions that return `unit`.

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