11---
2- title : Guide - React - Config Provider
2+ title : Guide - React - Provider
33sidebar_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
99to create a consistent behavior for data fetching and submission across your entire application, avoiding repetitive
1010setup 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.
15152 . What are the ** configurable options** for ` useFetch ` and ` useSubmit ` .
16163 . 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
2323in your main ` App.tsx ` or ` index.tsx ` file. It takes a ` config ` prop where you can specify default settings for all
2424Hyper-fetch hooks.
2525
@@ -28,7 +28,7 @@ Here's how you can wrap your application with it:
2828``` tsx
2929import React from " react" ;
3030import 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
3434const 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
5454const root = ReactDOM .createRoot (document .getElementById (" root" ));
5555root .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.
0 commit comments