React.js Code Snippets
useDarkMode Hook
A React hook for tracking and detecting the browser dark mode state. Always returns a boolean indicating whether the device is in dark mode true
in dark mode, false
when not.
useDeviceSize Hook
A React hook for tracking and retrieving the device size. Always returns a string indicating the current device size (sm
, md
, lg
, etc).
Simple Scatter Plot
Plot some points on a chart and color them in.
Simple Line Chart
Make a line chart from with domain 0 to 1 and range from ymin to ymax. With red line.
Line Chart with Custom Domain
In case you want to see more than just x at the interval [0, 1]. See the implementation of the range() function.
Line Chart for Parametric Functions
For when x and y values are dependent on a third value. See the implementation of the range() function.