@equinor/fusion-framework-react-module
TypeScript icon, indicating that this package has built-in type declarations

3.1.12 • Public • Published

React Module

Concept

This module should provide React developers with utils for initializing and consume modules.

Usage

INTERNAL_MODULE

In general this package is implemented by framework/app scaffolding

  • @equinor/fusion-framework-react-app
  • @equinor/fusion-framework-react-framework

Requirements

  • React >= 17

this module requires React 17 or higher since the creation, configuration and initializing of modules are async. The provider must be wrapped in an Suspense components

Example

Create a provider component

import { Suspense } from 'react';

import http, { HttpModule } from '@equinor/fusion-framework-module-http';
import msal, { MsalModule } from '@equinor/fusion-framework-module-msal';

import { createModuleProvider } from '@equinor/fusion-framework-react-module';

export const ModuleProvider = createModuleProvider((config) => {
    config.auth.configureDefault({
        tenantId: 'MY_TENANT_ID',
        clientId: 'MY_CLIENT_ID',
        redirectUri: '/authentication/login-callback',
    });
    config.http.configureClient('foo', {
        baseUri: 'https://foo.bar',
        defaultScopes: ['FOO_CLIENT_ID/.default'],
    });
  },
  [http, msal]
)

Create a app component (consumer)

import { useModule } from '@equinor/fusion-framework-react-module';

const AppComponent = () => {
  const http = useModule('http');
  const client = http.createClient('foo');
  return (
    <button onClick={client.fetchAsync('/api/todo')}>Fetch todo</button>
  );
}

Render App

import ReactDOM from 'react-dom';

import { ModuleProvider } from './Provider';
import { AppComponent } from './AppComponent';

ReactDOM.render(
  <Suspense fallback={<span>Loading framework</span>}>
    <ModuleProvider>
      <AppComponent />
    </ModuleProvider>
  </Suspense>,
  document.getElementById('root')
);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.1.7-msal-v4-preview-4113a03adbbeaf888ca8bbe55cb89589b5f736ba0msal-v4-preview
3.1.7-msal-v3-preview-2fe00c7097b86959194d2c5f2c7e725a5d20bdc00msal-v3-preview
3.1.6-alpha-8601e3ca5d5b2d11057913cdfc04bbc5e908a5980alpha
3.1.12198latest
3.1.10-next-c88655f3c93bff52499b1301c9a009301f818f5a35next
3.1.9-beta-AH-test-778ecddcafac619d1bdc9be4a2c50f2f8c15cc682beta-AH-test
3.1.7-msal-0b0dadf270ee512f019a325c2f1586f91f9150a41msal

Version History

VersionDownloads (Last 7 Days)Published
3.1.12198
3.1.11196
3.1.10-next-c88655f3c93bff52499b1301c9a009301f818f5a35
3.1.10136
3.1.9411
3.1.9-beta-AH-test-778ecddcafac619d1bdc9be4a2c50f2f8c15cc682
3.1.8361
3.1.7194
3.1.7-msal-0b0dadf270ee512f019a325c2f1586f91f9150a41
3.1.7-msal-6cf764b628c2afdd64dfd06e42abc953d78556d20
3.1.7-msal-v3-preview-2fe00c7097b86959194d2c5f2c7e725a5d20bdc00
3.1.7-msal-v4-preview-4113a03adbbeaf888ca8bbe55cb89589b5f736ba0
4.0.0-next-663bed8344cc2ca0111705b05045173328b3104d0
3.1.695
3.1.6-alpha-8601e3ca5d5b2d11057913cdfc04bbc5e908a5980
3.1.6-alpha-3568e67f10954eda012742a1a7d48d1278943f380
3.1.6-alpha-df90c0f890db097d17d4b84fe6face63231439700
3.1.6-alpha-75e3f722dd6749be497453ee7568040421d00f520
3.1.6-alpha-1691ce366ff2e68db5722686eda883710ca88dea0
3.1.6-alpha-52e7df9067d9a1af015e2e6f0af2a5bcfb49f5210
3.1.6-alpha-2e0570c4bda6180049fc0620aa03048d737e58310
3.1.6-alpha-279c8ef0106d17f8a7907ce97c31123552f03d620
3.1.6-alpha-20bf0650f0d578683f2310b6d96c4ce0be96b7db0
3.1.6-alpha-afdec66178b3cac96597125945ba7e1b4ca2ca7e0
3.1.6-alpha-17c4eed176e5b4a0fcf867ed245471d3863af2370
3.1.50
3.1.41
3.1.30
3.1.20
3.1.10
3.1.00
3.0.82
3.0.71
3.0.60
0.0.0-next-202309151856120
3.0.50
3.0.40
3.0.31
3.0.20
3.0.10
3.0.1-next.10
3.0.1-next.00
3.0.00
2.0.20
2.0.10
2.0.00
1.1.20
1.1.10
1.1.00
1.0.150
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.1-next.10
1.0.0-alpha.00
0.2.50
0.2.40
0.2.20
0.2.10
0.2.00
0.1.00

Package Sidebar

Install

npm i @equinor/fusion-framework-react-module

Weekly Downloads

1,634

Version

3.1.12

License

ISC

Unpacked Size

106 kB

Total Files

26

Last publish

Collaborators

  • eslsa
  • martinforre
  • _odin_
  • gustav-eikaas