Tuesday, September 13, 2022

Show more button in React

//

import Button from './shared/btn';
import { useState } from 'react';

export default function Func() {
// set show more state and onClick
const [showMore, setShowMore] = useState(false);
const moreClick = () => {
setShowMore(!showMore);
};
   const html = [];

return (
<>
{showMore ? html : !html}
      <Button
id={'show-more'}
className={'btn'}
value={'Show more'}
onClick={moreClick}
/>{
</>
);
}

     <button

        className='btn'

        onClick={() => setShowMore(!showMore)}

        id='showMore'

      >

        <b>Show More...</b>

      </button>

No comments:

Post a Comment