forked from Ayushsinhahaha/HacktoberFest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.js
More file actions
36 lines (30 loc) · 700 Bytes
/
Copy pathHeader.js
File metadata and controls
36 lines (30 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import PropTypes from 'prop-types'
import { useLocation } from 'react-router-dom'
import Button from './Button'
const Header = ({ title, onAdd, showAdd }) => {
const location = useLocation()
return (
<header className='header'>
<h1>{title}</h1>
{location.pathname === '/' && (
<Button
color={showAdd ? 'red' : 'green'}
text={showAdd ? 'Close' : 'Add'}
onClick={onAdd}
/>
)}
</header>
)
}
Header.defaultProps = {
title: 'Task Tracker',
}
Header.propTypes = {
title: PropTypes.string.isRequired,
}
// CSS in JS
// const headingStyle = {
// color: 'red',
// backgroundColor: 'black',
// }
export default Header