Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@skbkontur/react-icons
Advanced tools
Для использования иконок необходимо установить пакет @skbkontur/react-icons
В 4.0 исходный код иконок распространяется в виде ES6 модулей. Это необходимо для обеспечения правильной работы tree-shaking.
Кроме этого все иконки доступны в виде именованного импорта из корня.
Если вы загружаете компоненты библиотеки в nodejs, например, в unit тестах, вам необходимо настроить трансформацию в CommonJS модулей из @skbkontur/react-icons
, чтобы избежать ошибки Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
. Для сборки бандла в webpack конфиге ничего дополнительно настраивать не нужно. В скором времени появится нативная поддержка ES Modules в Jest
type IconProps = {
color?: string;
name: IconName; // только для компонента Icon
size?: number | string;
};
type IconName =
| 'Menu'
| 'Add'
| 'ArchivePack'
| 'ArchiveUnpack'
| 'Attach'
| 'Baby'
| 'Backward'
| 'BarcodeScanner'
| 'Briefcase'
| 'Calculator'
| 'Calendar'
| 'Card'
| 'Certificate'
| 'Clear'
| ... 218 more ...
| 'Infiniti';
Для уменьшения размера бандла рекомендуется использовать компонент с конкретной иконкой
import { Icon } from './';
import { Ok } from './icons/Ok';
<div>
<Ok size={16} color="red" />
<Icon name="Ok" size={24} color="blue" />
<Icon.Ok size={32} color="green" />
</div>;
Список изменений доступен по ссылке ссылке
import { Icon } from './';
<div>
<div style={{ columns: '3' }}>
{Object.keys(Icon).map(name => {
return (
<div style={{ margin: '2px' }}>
<Icon name={name} />
<span style={{ marginLeft: '2px' }}> - {name}</span>
</div>
);
})}
</div>
</div>;
FAQs
React SVG icons
The npm package @skbkontur/react-icons receives a total of 10 weekly downloads. As such, @skbkontur/react-icons popularity was classified as not popular.
We found that @skbkontur/react-icons demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.