Refactoring a vanilla JS app with state based UI
About a year ago, I recorded myself building a simple vanilla JS in real time in under 20 minutes.
One of my students mentioned that he would like to see a video of me refactoring code live. Today, I put together a video of me refactoring my Who’s Driving app to use state-based UI instead of lots of manual DOM manipulation.
Note: I should have added a function to sanitize user inputs to protect against XSS attacks. Totally forgot to!
And here are the related assets:
- Source code on GitHub: https://gist.github.com/cferdinandi/5e0763c686be45ca0a686a1906a841af
- CodePen demo: https://codepen.io/cferdinandi/pen/zeoJqy