import { Canvas, Meta, Story } from '@storybook/addon-docs';
import ThemeProvider from 'src/theme';
yarn add @pangolindex/components
or
npm install @pangolindex/components
react
react-dom
@pangolindex/sdk ( for version see below mapping )
@pangolindex/components | @pangolindex/sdk |
---|---|
4.0.4 | 2.1.11 |
<4.1.0 | 3.0.1 |
4.1.0 | 3.1.2 |
4.1.1 - <=4.2.0 | 3.1.3 |
4.2.1-rc.0 - <=4.3.0 | 3.1.12 |
4.4.0 | 3.1.13 |
5.0.0 | 4.0.0 |
5.1.0 | 4.2.0 |
5.2.0 | 4.3.0 |
5.3.0 - 5.4.0 | 4.4.0 |
5.5.0 | 4.4.1 |
5.6.0 | 4.5.0 |
6.0.0 | 5.0.0 |
6.0.2 | 5.0.1 |
7.1.0 | 5.1.0 |
7.1.4 | 5.1.1 |
7.1.5 | 5.1.2 |
7.2.0 | 5.2.0 |
7.3.0 | 5.3.0 |
>=7.3.1 <7.3.5 | 5.3.1 |
>=7.3.5 <7.3.9 | 5.3.2 |
7.3.9 | 5.3.4 |
In your main file wrap your app with PangolinProvider
and Web3ReactProvider
:
Use version 6.0.9 of @web3-react/core
package.
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { NetworkContextName, PangolinProvider } from '@pangolindex/components';
import { createWeb3ReactRoot, Web3ReactProvider } from '@web3-react/core';
const Web3ProviderNetwork = createWeb3ReactRoot(NetworkContextName);
function getLibrary(provider: any): Web3Provider {
try {
const library = new Web3Provider(provider, 'any');
library.pollingInterval = 15000;
return library;
} catch (error) {
return provider;
}
}
// library -> web3.js provider
// chainId -> chain id with which user is connected
// account -> user's connected wallet address
// theme -> optional ( refer Theme guide to customize it )
ReactDOM.render(
<React.StrictMode>
<Web3ReactProvider getLibrary={getLibrary}>
<Web3ProviderNetwork getLibrary={getLibrary}>
<PangolinProvider library={library} chainId={chainId} account={account} theme={theme}>
<App />
</PangolinProvider>
</Web3ProviderNetwork>
</Web3ReactProvider>
</React.StrictMode>,
document.getElementById('root'),
);
In PangolinProvider
you can pass custom theme. Follow Guide -> Theme
to customize theme.
If you are using redux in your application then you will need to use custom context https://react-redux.js.org/api/hooks#custom-context with your Provider.
- do
yarn
in example directory. - copy
.env.sample
to.env
- do
yarn
in components. - make sure you follow
setup example repo
steps - do
yarn dev:example
which will start app fromexample
directory. - as you develop components in
src
folder, you can keep testing it in example app. - once its developed you can use those new changes in interface repo.
- do
yarn publish
which will build the components and publish to npm.