The export statement is used to export functions, objects or primitive values from a module so they can be used in other files or applications.
Here are some examples of how to use export in JavaScript:
Exporting a single function:
index.tsx84 chars6 linesImporting a single function:
index.tsx103 chars4 lines
Exporting multiple functions/objects:
index.tsx124 chars11 linesImporting multiple functions/objects:
index.tsx136 chars5 lines
Exporting a single object:
index.tsx101 chars9 linesImporting a single object:
index.tsx90 chars4 lines
Note that the default keyword is used to export a single value from a module. Only one default export is allowed per module. When importing a module's default export, you can choose any name you like.
gistlibby LogSnag