useDigit

UseDigitExample

src/prod/numbers/useDigit.ts

import React from 'react';



export const useDigit = (intialState = 0) => {
	const [digit, setDigit] = React.useState(intialState);

	const setDigitSafe = (d: number) => {
		if (d >= 0 && d < 10) {
			setDigit(d);
		}
	};

	return [digit, setDigitSafe];
};

dist/prod/numbers/useDigit.js

import React from 'react';
export const useDigit = (intialState = 0) => {
    const [digit, setDigit] = React.useState(intialState);
    const setDigitSafe = (d) => {
        if (d >= 0 && d < 10) {
            setDigit(d);
        }
    };
    return [digit, setDigitSafe];
};

src/prod/numbers/useDigit.ts

import React from 'react';



export const useDigit = (intialState = 0) => {
	const [digit, setDigit] = React.useState(intialState);

	const setDigitSafe = (d: number) => {
		if (d >= 0 && d < 10) {
			setDigit(d);
		}
	};

	return [digit, setDigitSafe];
};