@8base-react/app-provider 中文文档教程

发布于 3年前 浏览 23 项目主页 更新于 3年前

8base App Provider

Universal 8base App Provider 加载片段模式并将其与身份验证和表模式一起提供给 Apollo 客户端。

API

Table of Contents

EightBaseAppProvider

EightBaseAppProvider 通用提供程序,它加载片段模式并将其与身份验证和表模式一起提供给 Apollo 客户端。

Properties

  • uri string? The 8base API field schema.
  • authClient Object? The 8base auth client.
  • onRequestSuccess Function? Callback which is executed when a request is successful.
  • onRequestError Function? Callback which is executed when a request fails.
  • extendLinks Function? Function to extend the standard array of links.
  • children Function? The render function.

Usage

import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { EightBaseAppProvider } from '@8base/app-provider';
import { WebAuth0AuthClient } from '@8base/web-auth0-auth-client';
import { EightBaseBoostProvider, Loader } from '@8base/boost';

import { Routes } from './routes';

const authClient = new WebAuth0AuthClient({
  domain: AUTH_DOMAIN,
  clientId: AUTH_CLIENT_ID,
  redirectUri: `${window.location.origin}/auth/callback`,
  logoutRedirectUri: `${window.location.origin}/auth`,
  workspaceId: 'workspace-id',
});

const Application = () => (
  <BrowserRouter>
    <EightBaseBoostProvider>
      <EightBaseAppProvider uri={ process.env.REACT_APP_8BASE_API_URL } authClient={ authClient }>
        {
          ({ loading }) => loading ? <Loader /> : <Routes />
        }
      </EightBaseAppProvider>
    </EightBaseBoostProvider>
  </BrowserRouter>
);

export { Application };

8base App Provider

Universal 8base App Provider loads fragments schema and provides it to Apollo client, along with authentication and table schema.

API

Table of Contents

EightBaseAppProvider

EightBaseAppProvider universal provider which loads fragments schema and provides it to Apollo client, along with authentication and table schema.

Properties

  • uri string? The 8base API field schema.
  • authClient Object? The 8base auth client.
  • onRequestSuccess Function? Callback which is executed when a request is successful.
  • onRequestError Function? Callback which is executed when a request fails.
  • extendLinks Function? Function to extend the standard array of links.
  • children Function? The render function.

Usage

import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { EightBaseAppProvider } from '@8base/app-provider';
import { WebAuth0AuthClient } from '@8base/web-auth0-auth-client';
import { EightBaseBoostProvider, Loader } from '@8base/boost';

import { Routes } from './routes';

const authClient = new WebAuth0AuthClient({
  domain: AUTH_DOMAIN,
  clientId: AUTH_CLIENT_ID,
  redirectUri: `${window.location.origin}/auth/callback`,
  logoutRedirectUri: `${window.location.origin}/auth`,
  workspaceId: 'workspace-id',
});

const Application = () => (
  <BrowserRouter>
    <EightBaseBoostProvider>
      <EightBaseAppProvider uri={ process.env.REACT_APP_8BASE_API_URL } authClient={ authClient }>
        {
          ({ loading }) => loading ? <Loader /> : <Routes />
        }
      </EightBaseAppProvider>
    </EightBaseBoostProvider>
  </BrowserRouter>
);

export { Application };
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文