Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Last active May 12, 2025 11:27
Show Gist options
  • Save sunmeat/2c771f9330a018c35713a75850ac8580 to your computer and use it in GitHub Desktop.
Save sunmeat/2c771f9330a018c35713a75850ac8580 to your computer and use it in GitHub Desktop.
named export
// 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