~/talk

From Imperative to Declarative: Simplifying JavaScript APIs with React.js

Talkat UtahJS Conf 2023 · on Friday, 2023-09-15· [react, javascript]
links:none on file
slides:none on file

Shows how to wrap the Google Maps JavaScript API in a declarative React component using the Google Maps loader and the Maps and Marker constructors, a custom useMap hook that returns a container ref and map ref, and small hooks (useCenter, useZoom, useIdle) that run imperative updates inside useEffect. Uses context to let child Marker components new up markers, keeps the map in a ref to avoid rerenders, and lets external state control center/zoom while encapsulating imperative logic.

AI-written summary · about

  1. 0:00Introduction
  2. 1:09Imperative vs declarative
  3. 3:16Code examples comparison
  4. 5:45Benefits of declarative code
  5. 7:56Simplifying JavaScript APIs
  6. 10:04Declarative Google Maps API
  7. 13:58Handling map center prop
  8. 15:44Adding zoom and idle hooks
  9. 16:24Adding markers with context
  10. 18:53Conclusion and benefits
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.