⚠️ This lesson is retired and might contain outdated information.

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

Social Share Links

Send Tweet
Published 4 years ago
Updated 2 years 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.

egghead
egghead
~ 16 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today