Skip to content

Commit ca969e0

Browse files
committed
chore: entries are actually Js.t
1 parent 0731ee7 commit ca969e0

9 files changed

+38
-105
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11

bsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
],
2525
"suffix": ".bs.js",
26-
"bs-dependencies": ["reason-react", "@glennsl/bs-json", "bs-webapi"],
26+
"bs-dependencies": ["reason-react", "bs-webapi"],
2727
"bs-dev-dependencies": ["bs-react-testing-library", "@glennsl/bs-jest"],
2828
"refmt": 3
2929
}

docs/Index.bs.647ddf51.js.map

-1
This file was deleted.

docs/Index.bs.647ddf51.js renamed to docs/Index.bs.89918e33.js

+13-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Index.bs.89918e33.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<!DOCTYPE html><html lang="en"><head><meta
2-
charset="UTF-8"><title>bs-react-is-visible</title></head><body> <div
3-
id="root"></div> <script src="./Index.bs.647ddf51.js"></script>
2+
charset="UTF-8"><title>bs-react-is-visible</title></head><body> <div id="root"></div> <script
3+
src="./Index.bs.89918e33.js"></script>
44
</body></html>

package-lock.json

+13-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"reason-react": ">=0.7.0"
3838
},
3939
"dependencies": {
40-
"@glennsl/bs-json": "^3.0.0",
4140
"bs-webapi": "^0.14.3",
4241
"react-is-visible": "^1.0.4"
4342
},
@@ -46,6 +45,7 @@
4645
"bs-platform": "^5.0.1",
4746
"bs-react-testing-library": "^0.5.0",
4847
"intersection-observer": "^0.6.0",
48+
"lodash": ">=4.17.13",
4949
"parcel-bundler": "^1.12.3",
5050
"react": "^16.8.0",
5151
"react-dom": "^16.8.0",

src/ReactIsVisible.re

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module VO = {
2+
type intersectionObserverEntry = {. "isIntersecting": bool};
3+
24
[@bs.val] [@bs.scope "VisibilityObserver"] [@bs.module "react-is-visible"]
35
external unwatch: Dom.element => unit = "unwatch";
46

57
[@bs.val] [@bs.scope "VisibilityObserver"] [@bs.module "react-is-visible"]
6-
external watch: (Dom.element, Js.Json.t => unit) => unit = "watch";
8+
external watch: (Dom.element, intersectionObserverEntry => unit) => unit =
9+
"watch";
710

811
[@bs.val] [@bs.scope "VisibilityObserver"] [@bs.module "react-is-visible"]
9-
external getSubscribers: unit => 't = "getSubscribers";
10-
11-
module Decode = {
12-
let entry = entry => Json.Decode.(entry |> field("isIntersecting", bool));
13-
};
12+
external getSubscribers: unit => 'subscriberList = "getSubscribers";
1413
};
1514

1615
let useIsVisible = () => {
@@ -19,7 +18,7 @@ let useIsVisible = () => {
1918

2019
React.useEffect0(() => {
2120
let handleVisibilityChange = entry =>
22-
setIsVisible(_ => entry |> VO.Decode.entry);
21+
setIsVisible(_prevIntersecting => entry##isIntersecting);
2322

2423
let domElement =
2524
switch (nodeRef |> React.Ref.current |> Js.Nullable.toOption) {

0 commit comments

Comments
 (0)