Skip to content

Commit

Permalink
Add TypeScript types section to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
desko27 committed Aug 14, 2024
1 parent f996f6f commit 0d334e0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Present a piece of UI to the user, wait for it to be used and get the response d
- βœ… Confirmations, dialogs
- βœ… Notifications, toasts
- βœ… Popup forms, modals
- βœ… Or anything! πŸ§‘β€πŸ”§ [Build your thing](#-build-your-thing)
- βœ… Or anything! πŸš€ [Build your thing](#-build-your-thing)

# Usage

Expand All @@ -76,7 +76,7 @@ const accepted = await Confirm.call({ message: 'Continue?' })
# Setup

## 1. 🎁 Wrap your component
## 1. βš›οΈ Wrap your component

```tsx
import { createCallable } from 'react-call'
Expand Down Expand Up @@ -113,7 +113,7 @@ Place `Root` once, which is what listens to every single call and renders it. An
> [!WARNING]
> Since it's the source of truth, there can only be one `Root`. Avoid placing it in multiple locations of the React Tree at the same time, an error will be thrown if so.
# πŸ§‘β€πŸ”§ Build your thing
# πŸš€ Build your thing

Again, this is no way limited to confirmation dialogs. You can build anything!

Expand All @@ -129,6 +129,22 @@ const userAction = await Toast.call({

But it's just another idea. It all depends on what you're building. The only thing `react-call` does is let you call components imperatively βš›οΈ πŸ“‘

# TypeScript types

You won't need them most likely, but if you want to split the component declaration and such, you may use the types under the `ReactCall` namespace:

```tsx
import type { ReactCall } from 'react-call'
```

Type | Description
--- | ---
ReactCall.Function<Props, Response> | The call() method
ReactCall.Context<Props, Response> | The call prop in UserComponent
ReactCall.Props<Props, Response> | Your props + the call prop
ReactCall.UserComponent<Props, Response> | What is passed to createCallable
ReactCall.Callable<Props, Response> | What createCallable returns

# Errors

Error | Solution
Expand Down

0 comments on commit 0d334e0

Please sign in to comment.