Skip to content

Commit

Permalink
fix: don't nest useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik Kullman authored and cristinecula committed Jun 24, 2020
1 parent 597748b commit 06915c6
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/use-data-nav.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { useMemo } from 'haunted';
import { useIncompleteTemplate } from './use-incomplete-template';
import { useCache } from './use-cache';

export const useDataNav = el => {
const incompleteTemplates = useMemo(() => ({
export const useDataNav = el => ({
cache: useCache(el),
incompleteTemplates: {
[el.selected - 1]: useIncompleteTemplate(el.selected - 1, el.items.length),
[el.selected]: useIncompleteTemplate(el.selected, el.items.length),
[el.selected + 1]: useIncompleteTemplate(el.selected + 1, el.items.length)
}), [el.selected, el.items.length]);
return {
cache: useCache(el),
incompleteTemplates
};
};
}
});

0 comments on commit 06915c6

Please sign in to comment.