This video is available to students only

Implementing Scroller

Writing code for the Scroller library and exporting it for users.

Writing a hook#

Open up the Scroller directory and navigate to the src directory. Create a new file called useScroller.js. Enter the following code:

Let's break down what each line of the code above is doing. We'll start by exporting a function called useScroller which takes an options object which will tell us where to scroll to in the x/y coordinates, and if we should scroll smoothly.

 

This page is a preview of Creating React Libraries from Scratch

Please select a discussion on the left.