Refactor Commonly Used Variables Into a Utils File to Be Shared Across Our React App

Ian Jones
InstructorIan Jones

Share this video with your friends

Send Tweet
Published 2 years ago
Updated 2 months ago

We refactor APP_ID and CLIENT_URL out of the index.js file to prepare our application to share these variables across multiple files.

Instructor: [0:00] Let's go back to our app. I'm going to open up a new terminal and going to make a directory called utils. Then I'm going to touch a file called src/utils/auth.js. I'll switch to it. We'll need to export const appId.

[0:33] This is the same appId we have in here. I'm just moving these variables over to a utils file. Then we'll take this. We'll go export const, and then we'll interpolate this and go appId. Inside of our index.js file, we will import clientURL from '.utils/auth'. Everything works fine. We're just getting that same error.