Skip to content

Commit 1a0ea19

Browse files
feat: preload next question data
1 parent 7e552bf commit 1a0ea19

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/*
22
public/*
33
build/*
44
config/*
5+
dist/*

src/js/views/JsExercise.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const JsExercise = ({ match }) => {
5757
}, [data, match]);
5858

5959
Prism.highlightAll();
60+
6061
useEffect(() => {
6162
import(`../../../data/javascript/${match.params.exercise}/index.json`).then(
6263
json => {
@@ -71,6 +72,20 @@ const JsExercise = ({ match }) => {
7172
});
7273
}, [match]);
7374

75+
useEffect(() => {
76+
// preload next question
77+
console.log(
78+
'match',
79+
match.params.exercise,
80+
'next question',
81+
nextQuestion.key,
82+
);
83+
import(
84+
`!raw-loader! ../../../data/javascript/${nextQuestion.key}/question.js`
85+
);
86+
import(`../../../data/javascript/${nextQuestion.key}/index.json`);
87+
}, [match, nextQuestion]);
88+
7489
return (
7590
<Container className="mt-3 mb-3">
7691
<h2>{data.title}</h2>

0 commit comments

Comments
 (0)