Altcademy - a Forbes magazine logo Best Coding Bootcamp 2023

How to make link to resume in ReactJS

What is ReactJS?

Before diving into the nitty-gritty of creating a resume link in ReactJS, it's important to clarify what ReactJS is. ReactJS is a popular JavaScript library that's used to build user interfaces, particularly for single-page applications. It allows developers to build reusable UI components.

No need to be frightened by the jargon. Think of a library as a set of prewritten code that you can call upon to perform common tasks. It's like a toolbox where each tool has its own unique function. Single-page applications, on the other hand, are web applications that load a single HTML page and dynamically update that page as the user interacts with the app.

What You Need to Get Started

To start creating a resume link in ReactJS, you need to have Node.js and npm (node package manager) installed on your computer. Node.js is a runtime environment that runs JavaScript on your computer, while npm is a package manager that installs, updates, and manages the libraries that your project depends on.

Setting Up a New React Project

First, we need to set up a new React project. You can do this by opening your terminal or command prompt and running the following command:

npx create-react-app resume-link

This command uses npx, a package runner tool that comes with npm. create-react-app is a command that sets up a new React project with an optimal development environment. resume-link is the name of our new project.

Now, let's dive into the fun part: creating a resume link. In your project's src folder, create a new file named ResumeLink.js. This is where we'll create our ResumeLink component.

In React, a component is a reusable piece of code that manages its own content, presentation, and behavior. Think of it as a LEGO block. Just like how you can put LEGO blocks together in different ways to build unique structures, you can put components together to build unique web applications.

Here's what the code in ResumeLink.js should look like:

import React from 'react';

function ResumeLink() {
  return (
    <a href="resume.pdf" target="_blank" rel="noreferrer">
      View my resume
    </a>
  );
}

export default ResumeLink;

This code defines a new function named ResumeLink that returns a link (<a>). href="resume.pdf" specifies the location of the resume file. target="_blank" opens the link in a new tab. rel="noreferrer" is a security measure that prevents the new page from being able to access the window object of the original page.

To use the ResumeLink component, you need to import it in the file where you want to use it. In most cases, this will be your App.js file.

Here's what your App.js file should look like:

import React from 'react';
import ResumeLink from './ResumeLink';

function App() {
  return (
    <div className="App">
      <h1>Hello, world!</h1>
      <ResumeLink />
    </div>
  );
}

export default App;

This code renders a Hello, world! heading and the ResumeLink component.

Running Your React App

To see your shiny new resume link in action, run the following command in your terminal:

npm start

This command starts a local development server and opens your app in a web browser. If you've followed all the steps correctly, you should see a Hello, world! heading and a link that says View my resume.

Conclusion

Congratulations! You’ve just created your first link to a resume in ReactJS. By understanding and implementing the steps above, you've taken a significant stride in your journey as a ReactJS developer. This may seem like a small step, but as the old saying goes, "Even the longest journey begins with a single step."

In the process, you've learned how to set up a new React project, create a new component, import a component, and run your React app. Remember, programming is like cooking. Each ingredient (or in this case, piece of code) has a specific role. By understanding what each ingredient does and how they blend together, you can create delicious dishes—or in this case, amazing web applications.

So, go forth and experiment. Try adding more components, styling your components, or even creating a whole new project. The world of ReactJS is your oyster!