Skip to content

Commit

Permalink
Higher Order Component
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Oct 19, 2022
1 parent 418d8e8 commit a5d1e61
Show file tree
Hide file tree
Showing 8 changed files with 1,341 additions and 1,362 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*node_modules*
*.parcel-cache*
23 changes: 0 additions & 23 deletions portfolio/.gitignore

This file was deleted.

2,659 changes: 1,330 additions & 1,329 deletions portfolio/dist/index.975ef6c8.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion portfolio/dist/index.975ef6c8.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions portfolio/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from 'react';
import Projects from './Projects';
import SocialProfiles from './SocialProfiles';
import Title from './Title';
import Header from './Header';
import profile from '../assets/profile.png';

class App extends Component {
Expand All @@ -15,7 +14,6 @@ class App extends Component {
render() {
return (
<div>
<Header />
<img src={profile} alt='profile' className='profile' />
<h1>Hello!</h1>
<p>My name is David.</p>
Expand Down
9 changes: 6 additions & 3 deletions portfolio/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';

const Header = () => {
const Header = ({ children }) => {
const style = {
display: 'inline-block',
margin: 10,
Expand All @@ -10,8 +10,11 @@ const Header = () => {

return (
<div>
<h3 style={style}><Link to='/'>Home</Link></h3>
<h3 style={style}><Link to='/jokes'>Jokes</Link></h3>
<div>
<h3 style={style}><Link to='/'>Home</Link></h3>
<h3 style={style}><Link to='/jokes'>Jokes</Link></h3>
</div>
{children}
</div>
)
}
Expand Down
2 changes: 0 additions & 2 deletions portfolio/src/components/Jokes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import Header from './Header';

const Joke = ({ joke: { setup, punchline } }) => (
<p style={{ margin: 20 }}>{setup} <em>{punchline}</em></p>
Expand All @@ -25,7 +24,6 @@ class Jokes extends Component {
render() {
return (
<div>
<Header />
<h2>Highlighted Joke</h2>
<Joke joke={this.state.joke} />
<hr />
Expand Down
5 changes: 3 additions & 2 deletions portfolio/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import Header from './components/Header';
import App from './components/App';
import Jokes from './components/Jokes';
import './index.css';
Expand All @@ -10,8 +11,8 @@ const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<BrowserRouter history={createBrowserHistory()}>
<Routes>
<Route path='/' element={<App />} />
<Route path='/jokes' element={<Jokes />} />
<Route path='/' element={<Header><App /></Header>} />
<Route path='/jokes' element={<Header><Jokes /></Header>} />
</Routes>
</BrowserRouter>
);

0 comments on commit a5d1e61

Please sign in to comment.