-
Notifications
You must be signed in to change notification settings - Fork 50
nick.rodriguez.atx.advanced.1 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3825a18
dda54b5
e5aafbf
8ce2b19
2444b0a
a65b9df
c2bd1d8
495b2d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import React from "react"; | ||
| // import logo from "./logo.svg"; moved to Header.js | ||
| import "./App.css"; | ||
| import Body from "./Body.js"; | ||
| import Footer from "./footer.js"; | ||
| import Header from "./Header.js"; | ||
| import ListOfUsers from "./ListOfUsers.js"; | ||
| import UserDetail from "./UserDetail.js"; | ||
| import propTypes from "prop-types"; | ||
|
|
||
|
|
||
| function App(props) { | ||
|
|
||
| return ( | ||
| <div className="App"> | ||
| <Header name="Nick" /> | ||
| <Body />{/* className = App-intro */} | ||
| {/* | ||
| <ComponentX/> | ||
| <UserDetail userDetail={props.usersDB} /> | ||
| */} | ||
|
|
||
| <ListOfUsers userNames={props.usersDB} /> | ||
|
|
||
|
|
||
| <Footer /> {/* Footer location*/} | ||
| </div> | ||
|
|
||
| ); | ||
| } | ||
|
|
||
| App.propTypes = { | ||
| usersDB: propTypes.array | ||
| }; | ||
|
|
||
|
|
||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| function Body() { | ||
| return ( | ||
|
|
||
| <h1> </h1> | ||
| /* | ||
| <p> className="App-intro"> | ||
| To get started, edit <code>src/App.js</code> and save to reload. | ||
| </p> | ||
| */ | ||
| ); | ||
| } | ||
|
|
||
| export default Body; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from "react"; | ||
| import logo from "./logo.svg"; | ||
|
|
||
| function Header(props) { | ||
|
|
||
| return ( | ||
| <div className="App-header"> | ||
| <img src={logo} className="App-logo" alt="logo" /> | ||
| <h2>Welcome to React {props.name} </h2> | ||
| <p>Test update Edits</p> | ||
| </div> | ||
| ); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| export default Header; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing propTypes |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import React, {Component} from "react"; // default component is without brackets | ||
| import propTypes from "prop-types"; | ||
| import UserDetail from "./UserDetail"; | ||
|
|
||
| class ListOfUsers extends Component { | ||
| constructor(...args) { // or constructor(props) | ||
| super(...args); // or super(props) | ||
| this.state = { | ||
| userWasClicked: false, | ||
|
|
||
|
|
||
|
|
||
| }; | ||
| } // end of constructor | ||
|
|
||
| handleUserClick(event) { | ||
| console.log("Handle click", event); | ||
| console.log("the id is: ",event.id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation... |
||
| this.setState({ | ||
| userWasClicked: !this.state.userWasClicked | ||
| }); | ||
| } // end of click handler | ||
|
|
||
|
|
||
| render() { | ||
|
|
||
| return ( | ||
| <div > | ||
| <hr /> | ||
| {this.props.userNames.map((userNames,x) => { | ||
| return ( | ||
| <p key={userNames.id} onClick={this.handleUserClick.bind(this, this.props.userNames[x])}> | ||
| {this.props.userNames[x].first_name} | ||
| {this.props.userNames[x].last_name} | ||
| {this.props.userNames[x].id}</p> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Closing p tag should be on the same indentation level as opening tag. |
||
| );// end of return; | ||
| }) // end of map function | ||
| } // end of display usernames | ||
| <UserDetail num={this.props.userNames} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation... |
||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| ListOfUsers.propTypes = { | ||
| userNames: propTypes.array, | ||
| }; | ||
|
|
||
| export default ListOfUsers; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React, {Component} from "react"; // default component is without brackets | ||
| import propTypes from "prop-types"; | ||
|
|
||
| class ListOfUsers extends Component { | ||
| constructor(...args) { // or constructor(props) | ||
| super(...args); // or super(props) | ||
| this.state = { | ||
| userWasClicked: false | ||
| }; | ||
| } // end of constructor | ||
|
|
||
| handleUserClick(event) { | ||
| console.log("Hanlde click", event); | ||
| console.log(this); | ||
| console.log(this.nameOfUser); | ||
| this.setState({ | ||
| userWasClicked: !this.state.userWasClicked | ||
| }); | ||
| } // end of click handler | ||
|
|
||
| render() { | ||
| return ( | ||
| <div > | ||
| <hr /> | ||
| {this.props.userNames.map((userNames,x) => { | ||
| return ( | ||
| <p key={userNames.id} onClick={this.handleUserClick.bind(this)} nameOfUser={this.props.userNames[x].first_name} > | ||
| {this.props.userNames[x].first_name} {this.props.userNames[x].last_name} {this.props.userNames[x].id}</p> | ||
| ); | ||
| })} | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| ListOfUsers.propTypes = { | ||
| userNames: propTypes.array, | ||
| }; | ||
|
|
||
| export default ListOfUsers; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import React, {Component} from "react"; | ||
| import propTypes from "prop-types"; | ||
|
|
||
|
|
||
| class UserDetail extends Component { | ||
| constructor (...args) { | ||
| super(...args); | ||
| this.state = { | ||
| userWasClicked: false | ||
| }; | ||
| } | ||
|
|
||
| render(){ | ||
| // console.log(this.props) | ||
| return ( | ||
| <div> | ||
|
|
||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| UserDetail.propTypes = { | ||
| userDetail: propTypes.shape({ | ||
| first_name: propTypes.string, | ||
| last_name: propTypes.string, | ||
| }) | ||
| }; | ||
|
|
||
|
|
||
| export default UserDetail; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Component1 extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h2>Component1</h2> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Component2 extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h2>Component2</h2> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Component3 extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h2>Component3</h2> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Component4 extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h2>Component4</h2> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Component5 extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h2>Component5</h2> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Component6 extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h3>Component6</h3> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from "react"; | ||
|
|
||
|
|
||
| export default class Footer extends React.Component { | ||
| render(){ | ||
| return (<div> | ||
| <h1></h1> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import React from "react"; | ||
| // import logo from "./logo.svg"; moved to Header.js | ||
| import "./App.css"; | ||
| import Body from './Body.js'; | ||
| import Footer from './footer.js'; | ||
| import Header from './Header.js'; | ||
| // import Component1 from './component1.js'; | ||
| // import Component2 from './component2.js'; | ||
| // import Component3 from './component3.js'; | ||
| // import Component4 from './component4.js'; | ||
| // import Component5 from './component5.js'; | ||
| // import Component6 from './component6.js'; | ||
| import ListOfUsers from './ListOfUsers.js'; | ||
| import UserDetail from './UserDetail.js'; | ||
|
|
||
|
|
||
| // function ComponentX() { | ||
| // return ( | ||
| // <h3> Texas </h3> | ||
| // ); | ||
| // } | ||
|
|
||
|
|
||
| function App(props) { | ||
| const userNames=props.users.map(function(users, index) { | ||
| return ( | ||
| <div> | ||
| {users.first_name}{users.last_name} | ||
| </div> | ||
| ); // end of return for MAP function | ||
| }); | ||
| const userItems2=props.users.map(function(users, index) { | ||
| return ( | ||
| <div key = {index}> | ||
| {users.address}{users.phone}{users.occupation}{users.avatar} | ||
| </div> | ||
| ); // end of return for MAP function | ||
|
|
||
| }); // end of APP fucntion | ||
|
|
||
| return ( | ||
| <div className="App"> | ||
| <Header name="Nick" /> | ||
| <Body />{/* className = App-intro */} | ||
| {/* <Component1/> | ||
| // <Component2/> | ||
| // <Component3/> | ||
| // <Component4/> | ||
| // <Component5/> | ||
| // <Component6/> | ||
| <ComponentX/> | ||
| <UserDetail /> | ||
| */} | ||
| <ListOfUsers userNames={userNames} /> | ||
| <UserDetail userItems2={userItems2} /> | ||
| <Footer /> {/* Footer location*/} | ||
| </div> | ||
|
|
||
| ); | ||
| } | ||
|
|
||
| export default App; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,18 @@ | ||
| import React from "react"; | ||
| import ReactDOM from "react-dom"; | ||
| import App from "./App"; | ||
| import App from "./components/App"; | ||
| import "./index.css"; | ||
| import users from "./users"; | ||
|
|
||
|
|
||
|
|
||
| function render() { | ||
| ReactDOM.render( | ||
| <App />, | ||
| <App usersDB={users} />, // send 'users' array to APP.js | ||
| document.getElementById("root") | ||
| ); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| render(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the indentation...