0.0.11 • Published 2 years ago

@oceanswapdefi/components v0.0.11

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

components

Ui Kit for Pangolin

Installation

yarn add @pangolindex/components

or

npm install @pangolindex/components

Install below dependancies as its peer dependancies

@oceanswapdefi/sdk
@web3-react/core
@web3-react/fortmatic-connector
@web3-react/portis-connector
@web3-react/walletconnect-connector
@web3-react/walletlink-connector
@pangolindex/web3-react-injected-connector
@gnosis.pm/safe-apps-web3-react

Getting started

Wrap your app with the PangolinProvider and pass the pangolin reducers into your redux store.

In your store pass the gelato reducers:

import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
import { save, load } from "redux-localstorage-simple";
import {
  pangolinReducers,
  PANGOLIN_PERSISTED_KEYS,
} from "@pangolindex/components";

const PERSISTED_KEYS: string[] = ["your_keys", ...PANGOLIN_PERSISTED_KEYS];

const store = configureStore({
  reducer: {
    ...your_reducers,
    ...pangolinReducers,
  },
  middleware: [
    ...getDefaultMiddleware({ thunk: false }),
    save({ states: PERSISTED_KEYS }),
  ],
  preloadedState: load({ states: PERSISTED_KEYS }),
});

export default store;

In your main file wrap your app with PangolinProvider:

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import store from "./state";
import { useWeb3React, Web3ReactProvider } from "@web3-react/core";
import { Provider } from "react-redux";
import { PangolinProvider } from "@pangolindex/components";
import getLibrary from "./utils/getLibrary";

const AppProvider = () => {
  const { library, account, chainId } = useWeb3React();

  return (
    <PangolinProvider
      library={library}
      chainId={chainId}
      account={account as string}
    >
      <App />
    </PangolinProvider>
  );
};

ReactDOM.render(
  <React.StrictMode>
    <Web3ReactProvider getLibrary={getLibrary}>
      <Provider store={store}>
        <AppProvider />
      </Provider>
    </Web3ReactProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

development flow

  1. do yarn in components
  2. do yarn dev which will watch for any files changes and recompiles files
  3. do yalc link "@pangolindex/components" in the project where you want to use components

Incase react hook violation error comes, in that case follow below steps also.

  1. do yarn link in <project_root>/node_modules/react.
  2. do yarn link react in components which will symlink react which are being used by project.

Publish flow

  • do yarn publish which will build the components and publish to npm.
0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago