Last active
May 12, 2025 11:27
-
-
Save sunmeat/2c771f9330a018c35713a75850ac8580 to your computer and use it in GitHub Desktop.
named export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// utils.jsx: | |
export function add(a, b) { return a + b; } | |
export function subtract(a, b) { return a - b; } | |
export const PI = 3.14; | |
// another file | |
import { add } from './utils'; // импортируем только add | |
import { add, subtract, PI } from './utils'; // импортируем всё | |
// именованные экспорты — лучший выбор по умолчанию. | |
// default — для случаев, когда экспортируется единственный объект или компонент, и если не важно, как он будет назван при импорте. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment