|
|
|
|
|
by chrisdalke
2017 days ago
|
|
One other common use for useRef that isn't mentioned here is to bridge your React component with a JS library outside the React ecosystem. For example, if you wanted to instantiate a charting library like uPlot (https://github.com/leeoniya/uPlot) you might instantiate a uPlot object storing state and methods for the chart. You can perform the chart initialization in a useEffect hook, and use a ref to keep a reference to the instance you've created. |
|