Use of Import-component.js in React with AEM
If you are using the archetype used in part 1 , then your react module contains a file called import-components.js .
1.What is the Use of import-component.js ?
You need to import the components inside import-components.js , Otherwise, you will not be able to show your component into the page.
i.e.
Here is the location of index.js file in react module.
Because at the end this file is called on the index.js file, and this index.js file renders on the page.
2. Is it necessary to use import-component.js file ?
No, it is not necessary to include your component import-component.js file, you can directly call your component file inside index.js .
In this case , you have to call every component file inside index.js .
But for best practices we include all your components inside import-component.js and import that file inside index.js .
3. Can we change the name of import-component.js ?
Yes, It is also not mandatory to use that particular name, you can use any name of that file and import by that name.
Recent Comments