docs: добавить примеры React
All checks were successful
CI/CD Pipeline / build (push) Successful in 20s
CI/CD Pipeline / version (push) Successful in 5s
CI/CD Pipeline / docker (push) Successful in 1m15s
CI/CD Pipeline / deploy (push) Successful in 7s

- добавлен раздел примеров React в сайдбар
- добавлены примеры создания и композиции фабрик
- перенесены подробные React-примеры из раздела модулей
- обновлены сгенерированные артефакты документации
This commit is contained in:
2026-05-11 20:56:41 +03:00
parent 4cea1007ed
commit 5874d3604c
6 changed files with 836 additions and 159 deletions

View File

@@ -194,87 +194,11 @@ Business-модуль всегда экспортирует фабрику. Фа
Компоновка фабрик происходит на уровне модуля-потребителя: screen, layout, widget или любой другой модуль группы «Композиция».
### Структура business-модуля
### Примеры
```text
business/customer/
├── customer.factory.ts
├── index.ts
└── types/
├── customer.type.ts
├── customer-api.type.ts
├── customer-deps.type.ts
└── customer-factory.type.ts
```
Пример реализации фабрики в React см. в [Создание фабрики](/examples/react/factory).
### Типы
```ts
// business/customer/types/customer-api.type.ts
export type CustomerApi = {
useCustomer: () => Customer
CustomerCard: (props: CustomerCardProps) => ReactNode
}
```
```ts
// business/order/types/order-deps.type.ts
export type OrderDeps = {
customer: Pick<CustomerApi, 'useCustomer'>
}
```
```ts
// business/order/types/order-factory.type.ts
export type OrderFactory = (deps: OrderDeps) => OrderApi
```
### Фабрика без зависимостей
```ts
// business/customer/customer.factory.ts
import type { CustomerFactory } from './types/customer-factory.type'
export const customerFactory: CustomerFactory = () => {
return {
useCustomer,
CustomerCard,
}
}
```
### Фабрика с зависимостями
```ts
// business/order/order.factory.ts
import type { OrderFactory } from './types/order-factory.type'
export const orderFactory: OrderFactory = (deps) => {
return {
useOrder,
OrderCard,
}
}
```
### Композиция на уровне screen
```tsx
// screens/home/home.screen.tsx
import { customerFactory } from '@/business/customer'
import { orderFactory } from '@/business/order'
const customer = customerFactory()
const order = orderFactory({ customer })
const { useOrder, OrderCard } = order
export const HomeScreen = () => {
const currentOrder = useOrder()
return <OrderCard order={currentOrder} />
}
```
Пример композиции фабрик в React screen-модуле см. в [Композиция фабрик](/examples/react/factory-composition).
## Жизненный цикл