about summary refs log tree commit diff
path: root/website/sandbox/nut-score/src/ReducerFromReactJSDocs/ReducerFromReactJSDocs.bs.js
blob: 74322f4a8f45cf35c7a5a840975d822f0ef92f00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';

var Curry = require("bs-platform/lib/js/curry.js");
var React = require("react");

var initialState = /* record */[/* count */0];

function reducer(state, action) {
  if (action) {
    return /* record */[/* count */state[/* count */0] - 1 | 0];
  } else {
    return /* record */[/* count */state[/* count */0] + 1 | 0];
  }
}

function ReducerFromReactJSDocs(Props) {
  var match = React.useReducer(reducer, initialState);
  var dispatch = match[1];
  return React.createElement("div", undefined, React.createElement("div", undefined, "Count: ", String(match[0][/* count */0])), React.createElement("div", undefined, React.createElement("button", {
                      onClick: (function (_event) {
                          return Curry._1(dispatch, /* Decrement */1);
                        })
                    }, "-"), React.createElement("button", {
                      onClick: (function (_event) {
                          return Curry._1(dispatch, /* Increment */0);
                        })
                    }, "+")));
}

var make = ReducerFromReactJSDocs;

exports.initialState = initialState;
exports.reducer = reducer;
exports.make = make;
/* react Not a pure module */