This file contains hidden or 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
const express = require('express'); | |
const MongoClient = require('mongodb').MongoClient; | |
const server = express(); | |
const port = 3000; | |
server.get('/', (req, res) => res.send('Hello World!')); | |
server.get('/api/users', (req, res) => { | |
MongoClient.connect('mongodb://localhost:27017/REACTCA2', function (err, client) { | |
if (err) throw err |
This file contains hidden or 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, { Component } from "react"; | |
import axios from "axios"; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { users: [], searchTerm: '', alphabetical: 'az' }; | |
this.handleChange = this.handleChange.bind(this); |
This file contains hidden or 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 Comment extends React.Component { | |
constructor(props) { | |
super(props); | |
// Setup the state data | |
this.state = { | |
flagged: false | |
}; |
This file contains hidden or 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"; | |
// Component to represent a single User 'Card' (note: this is a class component so can use state) | |
// Classes used below are from Bulma, see index.html above | |
class User extends React.Component { | |
constructor(props) { | |
super(props); | |
// Setup the state data |
This file contains hidden or 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"; | |
// Component to represent a single User 'Card' (note: this is a class component so can use state) | |
// Classes used below are from Bulma, see index.html above | |
class User extends React.Component { | |
constructor(props) { | |
super(props); | |
// Setup the state data |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>React App</title> | |
<!-- Load bulma for styling - Could use an alternative such as Bootstrap --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css" /> | |
</head> | |
<body> | |
<div id="root"></div> | |
</body> |
This file contains hidden or 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"; | |
// This loads data from a file named 'data.json' in the same directory | |
import data from "./data"; | |
// Store the array of user objects in a variable | |
const users = data.results; // [{user},{user}, ...] | |
// Component to represent a single User 'Card' (note: this is a function component so cannot use state) | |
function User(props) { |
This file contains hidden or 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 Clicky extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {clickCount: 0}; | |
this.handleClick = this.handleClick.bind(this); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>React App</title> | |
<!-- Load bulma for styling - Could use an alternative such as Bootstrap --> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css" /> | |
</head> | |
<body> | |
<div id="root"></div> | |
</body> |
This file contains hidden or 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
{ | |
"results": [ | |
{ | |
"name": { | |
"title": "miss", | |
"first": "sara", | |
"last": "cavalcanti" | |
}, | |
"picture": { | |
"large": "https://randomuser.me/api/portraits/women/8.jpg", |
NewerOlder