Sign in Go Pro

Advanced React Native

Absolute Import Paths

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



Import statements in JavaScript are relative, but it can get difficult to handle import statements in a large React Native application - especially if the components are in a deeply nested folder structure.

We'll switch from relative to absolute imports by using a bit of a trick - by naming the folders in our application that we want to be "root" modules that we can import from.

Summary of Content:

  • Add a package.json file to each of the main folders in src
  • Add a name key in each package.json to name those folders, which will then be interpreted as modules
  • Change the relative import paths to absolute import paths




There are no comments on this lesson, start the conversation below ...

You need to go PRO to post comments.

Lessons in Advanced React Native