Default import can be called with an arbitrary name on Javascript

 Today I made an effort to learn some Javascript from Firstbyte's code.

I learned about the purpose of the export statement. 

 The export default ForEducators; is a statement written to export the function "ForEducators" in a default mode onto other files AKA module. When importing "ForEducators" into other modules, the default state of the import statement allows us to use any arbitrary name while calling 

Example: import EducatorComponent from './forEducators';

Here "EducatorComponent" is the arbitrary value that calls the "ForEducators" function from the forEducators module/file.

File name: forEducators.js
import React from "react";

function ForEducators() { //function name can start with an uppercase or be camel case
  return (
    <h1>
      Hello World!!
    </h1>
  );
}

export default ForEducators;

Comments

Popular posts from this blog

Text->code->flowchart

Render method in JSX