You can use the export
keyword to export functions, objects or values from one JavaScript file and then use the import
keyword in another file to import and use them.
Here is an example:
In file1.js
:
index.tsx183 chars12 lines
In file2.js
:
index.tsx297 chars12 lines
Note that the default
export is imported without curly braces and can have any name you'd like.
Make sure to specify the correct file path when importing from one file to another.
gistlibby LogSnag