@spectral-finance/react-core
v0.0.9
Published
## Installation
Downloads
2
Readme
react-core
Installation
npm i --save @spectral-finance/react-core
Usage
The library exports a context and a hook to manage bundles and scores.
Connect context with app
Wrap the main app component with CoreProvider
.
import { CoreProvider } from "@spectral-finance/react-core";
export const App = () => {
const providersLoader = {
mainnetProvider: () => new JsonRpcProvider('https://...'),
};
return (
<CoreProvider
config={{
chainId: '1',
nfcContract: '0x...',
providersLoader,
}}
>
<RouterOrHome />
</CoreProvider>
);
};
Use hook
The hook can be used anywhere inside the app context.
import { CoreProvider } from "@spectral-finance/react-core";
export const Home = () => {
const { account, bundle, web3, ...restOfCoreComponents } = useCore();
return (
<div>{account.address}</div>
);
};