Skip to content

Commit c74abbc

Browse files
authored
Merge pull request #122 from BetterTyped/docs/fix
Docs fix
2 parents bb31837 + e6fea22 commit c74abbc

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

documentation/blog/migrations/migrate-to-7.0.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ All React hooks (`useFetch`, `useSubmit`, etc.) have been updated to align with
119119
improvement, TypeScript will now raise an error if you attempt to dispatch a request without setting all required
120120
parameters (e.g., URL params, payload), preventing runtime errors.
121121

122-
### Provider Renamed: `<ConfigProvider />``<HyperFetchProvider />`
122+
### Provider Renamed: `<ConfigProvider />``<Provider />`
123123

124-
For better clarity and naming consistency, the `<ConfigProvider />` has been renamed to `<HyperFetchProvider />`. You'll
124+
For better clarity and naming consistency, the `<ConfigProvider />` has been renamed to `<Provider />`. You'll
125125
need to update this in your application's component tree.
126126

127127
```tsx
@@ -135,10 +135,10 @@ const App = () => {
135135
// code-editor-split
136136

137137
// Now
138-
import { HyperFetchProvider } from "@hyper-fetch/react";
138+
import { Provider } from "@hyper-fetch/react";
139139

140140
const App = () => {
141-
return <HyperFetchProvider>...</HyperFetchProvider>;
141+
return <Provider>...</Provider>;
142142
};
143143
```
144144

documentation/docs/guides/react/01-basics/config-provider.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
---
2-
title: Guide - React - Config Provider
2+
title: Guide - React - Provider
33
sidebar_label: ConfigProvider
44
---
55

66
# React Config Provider
77

8-
In Hyper-fetch, you can set default configurations for hooks using the `<ConfigProvider />` component. This allows you
8+
In Hyper-fetch, you can set default configurations for hooks using the `<Provider />` component. This allows you
99
to create a consistent behavior for data fetching and submission across your entire application, avoiding repetitive
1010
setup in individual components.
1111

1212
:::secondary What you'll learn
1313

14-
1. How to use the **`<ConfigProvider />`** to set **global configurations** for Hyper-fetch hooks.
14+
1. How to use the **`<Provider />`** to set **global configurations** for Hyper-fetch hooks.
1515
2. What are the **configurable options** for `useFetch` and `useSubmit`.
1616
3. How to **structure your application** to use the provider effectively.
1717

1818
:::
1919

2020
## Setup
2121

22-
The `<ConfigProvider />` acts as a context wrapper. You should place it at the root of your component tree, for example
22+
The `<Provider />` acts as a context wrapper. You should place it at the root of your component tree, for example
2323
in your main `App.tsx` or `index.tsx` file. It takes a `config` prop where you can specify default settings for all
2424
Hyper-fetch hooks.
2525

@@ -28,7 +28,7 @@ Here's how you can wrap your application with it:
2828
```tsx
2929
import React from "react";
3030
import ReactDOM from "react-dom/client";
31-
import { ConfigProvider } from "@hyper-fetch/react";
31+
import { Provider } from "@hyper-fetch/react";
3232

3333
// 1. Define your custom configuration
3434
const customConfig = {
@@ -50,13 +50,13 @@ function App() {
5050
return <div>...</div>;
5151
}
5252

53-
// 2. Wrap your app with the ConfigProvider
53+
// 2. Wrap your app with the Provider
5454
const root = ReactDOM.createRoot(document.getElementById("root"));
5555
root.render(
5656
<React.StrictMode>
57-
<ConfigProvider config={customConfig}>
57+
<Provider config={customConfig}>
5858
<App />
59-
</ConfigProvider>
59+
</Provider>
6060
</React.StrictMode>,
6161
);
6262
```
@@ -68,7 +68,7 @@ ensuring that your application maintains a consistent user experience with minim
6868

6969
:::success Congratulations!
7070

71-
You've learned how to use the `<ConfigProvider />` to manage global settings for Hyper-fetch hooks in React!
71+
You've learned how to use the `<Provider />` to manage global settings for Hyper-fetch hooks in React!
7272

7373
- You can set **default options** for `useFetch` and `useSubmit` across your app.
7474
- You can **centralize configuration** to keep your components cleaner.

documentation/docs/guides/react/01-basics/refreshing.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ page. Hyper-fetch provides a simple and efficient way to achieve this with the `
1414
1. How to **automatically refresh** data at a set interval.
1515
2. How to use the **`refresh`** and **`refreshTime`** options in `useFetch`.
1616
3. How to create a **live-updating component** to display fresh data.
17-
4. How to use **`DateInterval`** for clear and readable time definitions.
17+
4. How to use **`Time`** enum for clear and readable time definitions.
1818

1919
:::
2020

@@ -27,13 +27,15 @@ You can turn any `useFetch` hook into a polling mechanism by setting the `refres
2727
{/* We'll also display a "Last Updated" timestamp to show the refresh in action. */}
2828

2929
```tsx
30+
import { Time } from "@hyper-fetch/core"
31+
3032
function LiveActivityFeed() {
3133
const [lastUpdated, setLastUpdated] = React.useState(new Date());
3234

3335
// highlight-start
3436
const { data: activities, loading } = useFetch(getActivities, {
3537
refresh: true,
36-
refreshTime: DateInterval.second * 5,
38+
refreshTime: Time.second * 5,
3739
onSuccess: () => {
3840
setLastUpdated(new Date());
3941
},
@@ -65,8 +67,8 @@ function LiveActivityFeed() {
6567
### How It Works
6668

6769
1. **`refresh: true`**: This option enables the auto-refreshing feature for the hook.
68-
2. **`refreshTime: DateInterval.second * 5`**: This sets the polling interval. We specify that the data should be
69-
re-fetched every 5000 milliseconds (5 seconds). Using the `DateInterval` enum from `@hyper-fetch/core` makes the
70+
2. **`refreshTime: Time.second * 5`**: This sets the polling interval. We specify that the data should be
71+
re-fetched every 5000 milliseconds (5 seconds). Using the `Time` enum from `@hyper-fetch/core` makes the
7072
time definition more readable than just `5000`.
7173
3. **`onSuccess` callback**: We use the `onSuccess` callback to update a `lastUpdated` state variable every time a
7274
successful refresh occurs. This allows us to give visual feedback to the user that the data is fresh.
@@ -84,6 +86,6 @@ You've learned how to keep your application's data fresh with auto-refreshing!
8486
- You can enable **automatic polling** for any `useFetch` hook.
8587
- You know how to configure the **refresh interval** using `refreshTime`.
8688
- You can provide **visual feedback** to users to show when data was last updated.
87-
- You can use the helpful **`DateInterval`** enum for readable time values.
89+
- You can use the helpful **`Time`** enum for readable time values.
8890

8991
:::

documentation/docs/guides/react/01-basics/window-focus-blur.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ then try interacting with the browser window (e.g., switch to another tab and co
2727
tools to simulate being offline and online.
2828

2929
```tsx
30+
import { Time } from "@hyper-fetch/core"
3031
function WindowEventsDemo() {
3132
const [options, setOptions] = React.useState({
3233
refresh: true,
33-
refreshTime: DateInterval.second * 5,
34+
refreshTime: Time.second * 5,
3435
refreshOnFocus: true,
3536
refreshOnBlur: false,
3637
refreshOnReconnect: true,

packages/react/src/provider/provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const ConfigContext = React.createContext<ProviderValueType>({
88
});
99

1010
/**
11-
* Context provider with configuration for hooks
11+
* Provider with configuration for hooks
1212
* @param options
1313
* @returns
1414
*/

0 commit comments

Comments
 (0)