+ Powered by Next.js! +
+ +Population Lookup
+ { + const { value } = e.currentTarget + // Dynamically load libraries + const Fuse = (await import("fuse.js")).default + const _ = (await import("lodash")).default + + const fuse = new Fuse(countries, { + keys: ["name"], + threshold: 0.3 + }) + + const searchResult = fuse + .search(value) + .map((result) => result.item) + + const updatedResults = searchResult.length + ? searchResult + : countries + setResults(updatedResults) + + // Fake analytics hit + console.info({ + searchedAt: _.now() + }) + }} + /> + +-
+ {results.map((country) => (
+
-
+
+ {country.name} - {country.population.toLocaleString()} +
+
+ ))}
+
Code Sample
+Ever wondered how to write a function that prints Hello World?
+ + {isModalOpen && ( +
+