Skip to content

Commit 5ac81ca

Browse files
committed
added props and propTypes to the Navbar
1 parent 851aa8a commit 5ac81ca

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Navbar from "./componets/Navbar";
44
function App() {
55
return (
66
<>
7-
<Navbar />
7+
<Navbar title="Text Utils" aboutText="About Text Utils" />
88
</>
99
);
1010
}

src/componets/Navbar.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import React from "react";
2+
import PropTypes from "prop-types";
23

3-
export default function Navbar() {
4+
Navbar.propTypes = {
5+
title: PropTypes.string.isRequired,
6+
aboutText: PropTypes.string,
7+
};
8+
9+
Navbar.defaultProps = {
10+
title: "Set Title Here",
11+
aboutText: "About Text Here",
12+
};
13+
14+
export default function Navbar(props) {
415
return (
516
<nav className="navbar navbar-expand-lg navbar-light bg-light">
617
<div className="container-fluid">
718
<a className="navbar-brand" href="/">
8-
Navbar
19+
{props.title}
920
</a>
1021
<button
1122
className="navbar-toggler"
@@ -31,7 +42,7 @@ export default function Navbar() {
3142
</li>
3243
<li className="nav-item">
3344
<a className="nav-link" href="/">
34-
About
45+
{props.aboutText}
3546
</a>
3647
</li>
3748
</ul>

0 commit comments

Comments
 (0)