Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-credit-calculator

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-credit-calculator

Simple credit calculator

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

React Credit Calculator

Build Status

Features

  • Implementing simple credit calculators using React Context
  • Written on Typescript
  • Only function components and hooks

Installation

Using npm

npm i react-credit-calculator@^3.0

Usage

import * as React from "react";
import * as Calculator from "react-credit-calculator";

const conditions: Calculator.ControllerProps = {
    interestRate: 0.0175, // 1.75% per day
    amount: {
        min: 500,
        max: 2000,
        initial: 1000,
        step: 50,
    },
    rate: {
        min: 1,
        max: 30,
        initial: 7,
        step: 1,
    },
};

return (
    <Calculator.Controller {...conditions}>
    
        {/** Controls for amount */}
        <Calculator.ControlWrapper type="amount">
            <Calculator.Button>
                Decrease
            </Calculator.Button>
            <Calculator.Input />
            <Calculator.Button increase>
                Increase
            </Calculator.Button>
        </Calculator.ControlWrapper>
        
        
        {/** Controls for term */}
        <Calculator.ControlWrapper type="term">
            <Calculator.Button>
                Decrease
            </Calculator.Button>
            <Calculator.Input />
            <Calculator.Button increase>
                Increase
            </Calculator.Button>
        </Calculator.ControlWrapper>
        
        {/** Summary */}
        <Calculator.Label type={"term"} />
        <Calculator.Label type={"total"} />
        <Calculator.DateLabel />
    </Calculator.Controller>
);

Using context manually:

import * as React from "react";
import * as Calculator from "react-credit-calculator";

return (
    <Calculator.Controller>{/** Include props */}
        <Calculator.Context.Consumer>
            {(value) => console.log(value) /** do something */}
        </Calculator.Context.Consumer>
    </Calculator.Controller>
);

see ContextValue for details.

Suggests

Contributors

License

MIT

Keywords

FAQs

Package last updated on 30 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc