Instructor: First we'll create a new React app with npm init react-app and the name of your application. I'll call it cra2-sass, and immediately cd into the app after it's bootstrapped. Once everything is created, then I'll open up VS Code with code ., and start the React dev server with npm start.
Next, create a folder named react-link, and create a react-link.js file and react-link.scss file. In the react-link.js file, import react from react, and import ./react-link.scss, which is the Sass that we'll be using.
Now, we'll define our React component by exporting the defaults, getting props, and destructuring classname, children, and a bundle of other props in a Rest variable. Now, we'll return an anchor component.
For the classname, we'll give it a value of react-link, and pass along whatever classname the consumer may have provided. Next, spread the Rest object to provide the rest of the props to the underlying anchor. Last, but not least, pass along the children from the parent.
Switch to the react-link.scss file, and let's provide some styles. Create a react-link class, and make it position relative. Since this is Sass, we can nest our selectors, and make a before pseudo-element, with content of the atom emoji, giving a position of absolute, and a right of negative 1.5 ems.
Switching to the app.js component, we'll import react-link from react-link/react-link, and you'll notice that our server doesn't like that we're using Sass, but it does give a nice and helpful error message, indicating exactly what we need to do.
We'll copy the install command from the error, and proceed to install the node-sass dependency. Now, we'll stop the server using control-C, and restart it again with npm start. At this point, our server is happy again.
Now, we could replace the anchor component with our custom react-link component, and voila. We have an atom emoji next to our text.
If we inspect the elements, you could see the pseudo-element in the DOM that we defined in our react-link Sass file.