fix(toggle-btn): add missing prop-types

This commit is contained in:
dancingCycle 2022-06-08 10:23:12 +02:00
parent 91db4c3e8b
commit e27bae66a8
2 changed files with 8 additions and 6 deletions

View File

@ -2,21 +2,24 @@ import React from 'react';
import PropTypes from 'prop-types';
const ToggleBtn = (props) => {
//destructuring
const {btnState,btnTrue,btnFalse,descTrue,descFalse,btnOnClick} = props;
const { btnState, btnTrue, btnFalse, descTrue, descFalse, btnOnClick } =
props;
//render
return (
<>
<button onClick={btnOnClick}>
{btnState===false?btnFalse:btnTrue}
</button>
{btnState===false?descFalse:descTrue}
<button onClick={btnOnClick}>
{btnState === false ? btnFalse : btnTrue}
</button>
{btnState === false ? descFalse : descTrue}
</>
);
};
export default ToggleBtn;
ToggleBtn.propTypes = {
btnState: PropTypes.bool,
btnTrue: PropTypes.string,
btnFalse: PropTypes.string,
descTrue: PropTypes.string,
descFalse: PropTypes.string,
btnOnClick: PropTypes.func
};

View File

@ -5,7 +5,6 @@ import ToggleButton from '../components/toggle-button';
const Home = () => {
//handle state
const [btnState,setBtnState]=useState(false);
//toggle
const toggle=()=>{
setBtnState((btnState)=>!btnState);
};