@spectral-finance/spectral-modal
v0.0.1-beta-24
Published
Spectral React Modal for Score Calculation
Downloads
12
Readme
Spectral Modal
Calculate your Spectral Score in simple steps
How to install the SDK?
npm i @spectral-finance/spectral-modal
or
yarn add @spectral-finance/spectral-modal
How to use it?
1- Import SpectralProvider
and wrap your app
Wrap the main app component with SpectralProvider
and set your app's logo
URL for the UI.
import { SpectralProvider } from "@spectral-finance/spectral-modal";
export const App = () => {
return (
<SpectralProvider logo="yourLogoImageURL" partnerId="yourPartnerId">
<RouterOrHome />
</SpectralProvider>
);
};
2- Invoke Spectral score hook calculation
The useSpectral
hook can be used anywhere inside the app context. Once the score is calculated it will be served within the score
key provided by the hook.
import { SpectralProvider } from "@spectral-finance/spectral-modal";
export const Home = () => {
const { start, score } = useSpectral();
const [myScore, setMyScore] = useState();
useEffect(() => {
if (!score) {
console.log("Score not calculated");
return;
}
console.log(`Hooray! your score is ${score}`);
setMyScore(score);
}, [score]);
return (
<div>
<button type="button" onClick={start}>
Calculate Spectral Score
</button>
</div>
);
};