Skip to content

Commit

Permalink
State
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Oct 19, 2022
1 parent 2c3038d commit d8399e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 48 deletions.
23 changes: 14 additions & 9 deletions portfolio/src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import React, { Component } from 'react';

class RegularClass {}
class ComponentClass extends Component {}

const regularClassInstance = new RegularClass();
const componentClassInstance = new ComponentClass();

console.log('regularClassInstance', regularClassInstance);
console.log('componentClassInstance', componentClassInstance);

class App extends Component {
constructor() {
super();
this.state = { displayBio: true };
}

render() {
return (
<div>
<h1>Hello!</h1>
<p>My name is David. I'm a software engineer.</p>
<p>I'm always looking forward to work on meaningful projects.</p>
{
this.state.displayBio ? (
<div>
<p>I live in San Francisco, and code every day.</p>
<p>My favorite language is JavaScript, and I think React.js is awesome</p>
<p>Besides coding, I also love music and ramen!</p>
</div>
) : null
}
</div>
);
}
Expand Down
39 changes: 0 additions & 39 deletions portfolio/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,3 @@ import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);

class Animal {
constructor(name, age) {
this.name = name;
this.age = age;
}

speak() {
console.log('I am', this.name, 'and I am', this.age, 'years old');
}
}

const animal1 = new Animal('Simba', 3);
animal1.speak();

console.log(animal1);

class Lion extends Animal {
constructor(name, age, furColor, speed) {
super(name, age);
this.furColor = furColor;
this.speed = speed;
}

roar() {
console.log(
'ROOOAR! I have',
this.furColor,
'fur, and I can run',
this.speed,
'miles an hour!'
);
}
}

const lion1 = new Lion('Mufasa', 20, 'golden', 25);
lion1.speak();
lion1.roar();
console.log(lion1);

0 comments on commit d8399e1

Please sign in to comment.