Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usePopcorn

A movie search and personal-rating app — search for any movie, see its details, rate it yourself, and keep a running watched list with average ratings and stats. Built specifically to practice writing and reusing custom React hooks.

Tech stack: React (Create React App) · OMDb API

What I Built

  • Live movie search against the OMDb API with results rendered as you type.
  • A star-rating component (stars.js) built from scratch — hover states, click-to-rate, and half/full-star display — instead of pulling in a rating library.
  • Two custom hooks that do real work: useMovies (handles fetching, loading, and error state for the search, including request cancellation on new searches) and useLocalStorage (a generic hook that syncs any piece of state to localStorage automatically).
  • A watched-movies list with derived stats (average IMDb rating, average user rating, average runtime) computed from the list itself rather than stored separately.
  • Keyboard shortcuts — e.g. Escape to close a selected movie, using useRef and event listeners cleaned up properly on unmount.

What I Learned

  • Writing genuinely reusable custom hooks — useLocalStorage isn't specific to this app; I learned to design a hook so it takes the key and initial value as parameters instead of hardcoding them.
  • Handling race conditions in data fetching — useMovies taught me why you need to cancel or ignore stale requests when the user types fast and multiple fetches are in flight at once.
  • Derived state vs. stored state — computing the average ratings from the watched list on every render instead of maintaining a separate "stats" state that could drift out of sync.
  • useRef for things other than DOM nodes — using it to track values across renders without triggering a re-render (e.g. countdown/keyboard logic).
  • Building a UI control (star rating) from first principles instead of reaching for a library, to actually understand hover/click state management.

Getting Started

npm install
npm start

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages