Skip to content

Commit

Permalink
fix: Remove duplicates on the output
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Sep 27, 2020
1 parent a23eb56 commit 1e1d3b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions demo/src/Test3.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
React.useEffect2(
() => {
Document.addMouseDownEventListener(onClickHandler, document);
Some(
() => Document.removeMouseDownEventListener(onClickHandler, document),
);
},
(onClick, outsideContainer.React.current),
);
7 changes: 7 additions & 0 deletions src/Ppx.re
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ let raiseWithLoc = (~loc, msg, variables) =>

let diff = (list1, list2) => List.filter(x => !List.mem(x, list2), list1);

let rec unique = lst =>
switch (lst) {
| [] => []
| [h, ...t] => [h, ...unique(List.filter(x => x != h, t))]
};

let quotes = str => "'" ++ str ++ "'";

let getIdents = (expression: Parsetree.expression) => {
Expand Down Expand Up @@ -136,6 +142,7 @@ let useEffectExpand = (e: Parsetree.expression) =>
let missingDependencies =
result
|> List.map(Longident.name)
|> unique
|> List.map(quotes)
|> String.concat(", ");

Expand Down

0 comments on commit 1e1d3b5

Please sign in to comment.