This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
const users = [ | |
{ name: "Mary", age: 32, image: "https://randomuser.me/api/portraits/med/women/34.jpg"}, | |
{ name: "John", age: 22, image: "https://randomuser.me/api/portraits/med/men/52.jpg"}, | |
{ name: "Joe", age: 44 , image: "https://randomuser.me/api/portraits/med/men/25.jpg"} | |
]; | |
// User Component - function style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createSecret() { | |
//private variable | |
let secretNum = Math.round(Math.random() * 10); | |
//public function | |
let guessSecret = function(guess) { | |
return guess === secretNum ? 'Correct' : 'Try again'; | |
} | |
return guessSecret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import ReactDOM from 'react-dom'; | |
import {BrowserRouter, Route, Link} from 'react-router-dom'; | |
class Home extends React.Component { | |
render() { | |
return( | |
<div> | |
<h2>Home</h2> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class UserProfiles extends React.Component { | |
constructor(){ | |
super(); | |
this.state = { | |
users: [] | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class UserList extends React.Component { | |
render() { | |
const users = [{"id":1,"first_name":"Kevyn","last_name":"Charrette","email":"[email protected]"}, | |
{"id":2,"first_name":"Katha","last_name":"Borham","email":"[email protected]"}, | |
{"id":3,"first_name":"Clareta","last_name":"Mawford","email":"[email protected]"}]; | |
const list = users.map( u => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class UserList extends React.Component { | |
constructor() { | |
super(); | |
this.state = {userName: ''}; | |
} | |
componentWillMount() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class Listy extends React.Component { | |
render() { | |
const users = ['John','Jill','Joan','Jenny']; | |
// // the map iterator below is identical to this for loop | |
// const list = []; | |
// for(let i = 0; i < users.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class Listy extends React.Component { | |
render() { | |
const users = ['John','Jill','Joan','Jenny']; | |
// // the map iterator below is identical to this for loop | |
// const list = []; | |
// for(let i = 0; i < users.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class UserProfiles extends React.Component { | |
constructor(){ | |
super(); | |
this.state = { | |
name: {title: '', first: '', last: ''}, | |
image: '' | |
}; | |
// fix the this value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":1,"first_name":"Kevyn","last_name":"Charrette","email":"[email protected]"}, | |
{"id":2,"first_name":"Katha","last_name":"Borham","email":"[email protected]"}, | |
{"id":3,"first_name":"Clareta","last_name":"Mawford","email":"[email protected]"}, | |
{"id":4,"first_name":"Pryce","last_name":"Kytley","email":"[email protected]"}, | |
{"id":5,"first_name":"Brion","last_name":"Spofforth","email":"[email protected]"}, | |
{"id":6,"first_name":"Courtney","last_name":"Boagey","email":"[email protected]"}, | |
{"id":7,"first_name":"Selle","last_name":"Thorald","email":"[email protected]"}, | |
{"id":8,"first_name":"Olenka","last_name":"Fidgett","email":"[email protected]"}, | |
{"id":9,"first_name":"Dora","last_name":"Durdy","email":"[email protected]"}, | |
{"id":10,"first_name":"Godard","last_name":"Ledingham","email":"[email protected]"}, |