Base Components
Learn how base components register and load the components used frequently in our application.
We'll cover the following...
Overview
Base components usually consist of small components often used throughout an application. Typically, if we want to use a component, it has to be imported and then registered. What’s special about base components is that they’re imported and registered automatically for us. To make it work, we use Webpack’s require.context
function, as explained below.
Let’s assume we have this directory structure:
The registerBaseComponents
function has two steps. First, component files are retrieved using require.context
. The require.context
function accepts four arguments:
- The
directory
argument (String) - The