My friends and I enjoy puzzle hunts and knowing lots of random trivia is usually helpful. This made me think of creating Triviago partly as a training tool, partly as a fun side project, and partly as a way to explore newer frontend technologies.
In the end, the game has 3 'game modes':
Feeling Lucky | Normal Quiz | Sudden Death |
---|---|---|
![]() |
![]() |
![]() |
Slot machine tiles represent themes and 12 questions from each unique theme will be fetched | Choose multiple categories, set difficulty and limit number of questions | Player gets 30 hard questions, 10s to answer each question and lose lives if wrong/ no answer |
Start Vite Developer Server: npm run dev
Build Production: npm run build
Challenges
Documented in Process Notes
Key Learning Points
Future Plans
1. WDS React/Typescript multiselect component tutorial
2. FreeCodeCamp React/Typescript quiz app
1. Victor Toschi's vanilla DOM-Manipulation slot machine
I didn't read the Medium article, but focused on his Codepen. Took about 1h to fully understand and test what his JS logic was doing, then rewrote it in React.
Learning Points:
Got familiar with useRef: because my implementation still relies on CSS animations rather than state manipulation, could not rely on useState
to capture and send information to API function call. Used useRef instead to capture data from DOM without re-rendering.
Challenges: working with HTML DOM Object properties and Typescript was an interesting challenge. Previously without typechecking, I didn't think twice about doing something like the below. But with TS i was more mindful about optionally chaining properties.
// before:
onTransitionEnd={() => {
const last = document.getElementById("doorOne")?.lastChild.id;
// `.id` would throw err because it's not a guaranteed property
// setting useRef
tagInputs.current.push(`${last}`);
}}
//after:
onTransitionEnd={() => {
const nodes = document.getElementById("doorOne")?.children;
const last = nodes && nodes[nodes.length - 1]?.id;
// setting useRef
tagInputs.current.push(`${last}`);
}}