![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@skbkontur/react-ui
Advanced tools
yarn add @skbkontur/react-ui
import { Button, Toast } from '@skbkontur/react-ui';
const MyApp = () => (
<div>
Click this button <Button onClick={() => Toast.push('Hey!')}>Click me</Button>
</div>
);
Нужно использовать ThemeContext. Список переменных можно глянуть в ThemeShowcase
Начиная с версий @skbkontur/react-ui@3.10.0
и @skbkontur/react-ui-validations@1.7.0
, библиотека поддерживает работу
в React.StrictMode.
Некоторым компонентам библиотеки необходимо иметь доступ до корневой DOM-ноды своих children. Ранее для этого использовался метод findDomNode, который в StrictMode запрещён. Теперь получение DOM-ноды реализовано в библиотеке через ref, из-за чего появились некоторые требования к компонентам, передаваемым в Hint, Tooltip, Popup или Tab:
React.ForwardRef
:import { Hint } from '@skbkontur/react-ui';
const CustomFunctionComponent = React.forwardRef(
(props, ref) => <div ref={ref}>children text</div>
);
export const WithFunctionChildren = () => (
<React.StrictMode>
<Hint pos="top" text="Something will never be changed" manual opened>
<CustomFunctionComponent/>
</Hint>
</React.StrictMode>
);
useImperativeHandle
, возвращаемый объект должен реализовывать метод getRootNode
,
возвращающий DOM-ноду:import { Hint } from '@skbkontur/react-ui';
const ImperativeHandleComponent = React.forwardRef(function FN(_, ref) {
const rootNode = React.useRef < HTMLDivElement > (null);
React.useImperativeHandle(ref, () => ({
foo: 'bar',
getRootNode: () => rootNode.current,
}));
return <div ref={rootNode}>children text</div>;
});
export const WithImperativeHandleChildren = () => (
<React.StrictMode>
<Hint pos="top" text="Something will never be changed" manual opened>
<ImperativeHandleComponent/>
</Hint>
</React.StrictMode>
);
getRootNode
, возвращающий DOM-ноду:import { Hint } from '@skbkontur/react-ui';
class CustomClassComponent extends React.Component {
rootNode = React.createRef();
render() {
return <div ref={this.rootNode}>children text</div>;
}
getRootNode() {
return this.rootNode.current;
}
}
export const WithClassChildren = () => (
<React.StrictMode>
<Hint pos="top" text="Something will never be changed" manual opened>
<CustomClassComponent/>
</Hint>
</React.StrictMode>
);
В случае несоблюдения требования, будет использоваться старый метод findDomNode, который не совместим с StrictMode.
Подробнее в пулл-реквесте
Реакт позволяет создавать рут внутри рута. Но контекст между ними не прокидывается. Это вызывает проблемы в работе
различных выпадашек, типа Tooltip
, Select
, Modal
и других.
В версии 4.26.0
появился мехнизм, который решает большинство этих проблем. Если вложенный реакт-рут является виджетом,
то будет достаточно обновить библиотеку только в нём.
Однако, при удалении html-элемента, который был реакт-рутом, его необходимо предварительно явно размонтировать:
React.useLayoutEffect(
() => () => {
if (React.version === 17) {
rootRef.current && ReactDOM.unmountComponentAtNode(rootRef.current);
} else if (React.version === 18) {
setTimeout(() => reactRoot.current?.unmount());
}
},
[],
);
Анимации в компонентах отключаются любой из следующих глобальных переменных:
REACT_UI_TEST
process.env.NODE_ENV === 'test'
process.env.REACT_UI_TEST
process.env.REACT_APP_REACT_UI_TEST
process.env.STORYBOOK_REACT_UI_TEST
Начиная с версии 2.14.0, стало возможным передавать в компоненты свои css-классы для дополнительной стилизации. Однако, не стоит пользоваться этой возможностью для вмешательства во внутренние стили компонентов. Верстка компонентов может быть изменена в любой момент без предупреждения, что приведет к поломке ваших переопределенных стилей.
С версии 4.0 многие компоненты умеют адаптироваться под мобильные устройства. Подробнее об управлении этим поведением в MOBILES.md.
Мы рады любой сторонней помощи. Не стесняйтесь писать в issues
баги и идеи для развития библиотеки.
FAQs
UI Components
We found that @skbkontur/react-ui 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
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.