Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Merge pull request #56 from Astrocoders/memoize-query-simple
Browse files Browse the repository at this point in the history
Wrap simple query result in memo
  • Loading branch information
MargaretKrutikova authored Oct 22, 2019
2 parents d68a137 + 2e8a705 commit 1932f51
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Query.re
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,18 @@ module Make = (Config: Config) => {
[|jsResult|],
);

(
switch (result) {
| {loading: true} => Loading
| {error: Some(error)} => Error(error)
| {data: Some(data)} => Data(data)
| _ => NoData
},
result,
);
let simple =
React.useMemo1(
() =>
switch (result) {
| {loading: true} => Loading
| {error: Some(error)} => Error(error)
| {data: Some(data)} => Data(data)
| _ => NoData
},
[|result|],
);

(simple, result);
};
};
};

0 comments on commit 1932f51

Please sign in to comment.