index.js

import React from 'react';
import { useHistory } from 'react-router-dom';
import Button from '../button';

import './index.scss';

export default function BackBtn({ data }) {
  const history = useHistory();
  // const { id, name } = data;

  function clickHandler() {
    history.length > 1 ? history.goBack() : history.push('/');
  }

  return <Button buttonId="back-btn" buttonText="Back" iconId="arrow-left" onClickHandler={clickHandler} />;
}