+
Skip to content
Merged

V1 #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# react-utils
# @saul-atomrigs/react

리액트 유틸 함수 모음 라이브러리
A collection of abstracted utilities for react applications

### `createContext`
## Usage

인터페이스
### `createContext`

```ts
// index.d.ts
export function createContext<ContextValueType extends object | null>(
rootComponentName: string,
defaultContext?: ContextValueType
): readonly [
Provider: React.FC<ContextValueType & { children: React.ReactNode }>,
useContext: () => ContextValueType
];
```
```tsx
import { createContext } from '@saul-atomrigs/react';

### `QueryAsyncBoundary`
const [ThemeProvider, useTheme] = createContext<{ mode: 'light' | 'dark' }>(
'Theme'
);

인터페이스
function ChildComponent() {
const theme = useTheme();
console.log('🚀 ~ ChildComponent ~ theme:', theme);
return <p>current theme: {theme.mode}</p>;
}

```ts
// index.d.ts
export function QueryAsyncBoundary(props: {
pendingFallback: React.ReactNode;
rejecterFallback?: React.ReactNode;
children: React.ReactNode;
}): JSX.Element;
function App() {
return (
<ThemeProvider mode='light'>
<ChildComponent />
</ThemeProvider>
);
}
```
21 changes: 0 additions & 21 deletions eslint.config.js

This file was deleted.

1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/create-context';
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载