Skip to content

Commit ab1b4a0

Browse files
committed
refactor: add __prefetched on Component
1 parent 0c3e6eb commit ab1b4a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/plugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ export default ({ app: { router } }) => {
88
const predictions = Object.keys(guess()).sort((a, b) => a.probability - b.probability)
99
predictions.forEach(path => {
1010
router.getMatchedComponents(path).forEach(Component => {
11-
if (typeof Component === 'function') {
12-
try { Component() } catch (e) {}
11+
if (typeof Component === 'function' && !Component.__prefetched) {
12+
try {
13+
Component()
14+
Component.__prefetched = true
15+
} catch (e) {}
1316
}
1417
})
1518
})

0 commit comments

Comments
 (0)