├── src ├── index.css ├── index.js ├── App.test.js ├── App.js ├── App.css ├── Github.js └── logo.svg ├── public ├── favicon.ico └── index.html ├── .gitignore ├── package.json └── README.md /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javascript-playground/remote-data-react-screencasts/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | import './index.css'; 5 | 6 | ReactDOM.render( 7 | , 8 | document.getElementById('root') 9 | ); 10 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | }); 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # production 10 | build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | npm-debug.log 16 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import './App.css'; 3 | 4 | import GitHub from './Github.js'; 5 | 6 | class App extends Component { 7 | render() { 8 | return ( 9 |
10 | 11 |
12 | ); 13 | } 14 | } 15 | 16 | export default App; 17 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 80px; 8 | } 9 | 10 | .App-header { 11 | background-color: #222; 12 | height: 150px; 13 | padding: 20px; 14 | color: white; 15 | } 16 | 17 | .App-intro { 18 | font-size: large; 19 | } 20 | 21 | @keyframes App-logo-spin { 22 | from { transform: rotate(0deg); } 23 | to { transform: rotate(360deg); } 24 | } 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "remote-data-screencast", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "react-scripts": "0.7.0" 7 | }, 8 | "dependencies": { 9 | "react": "15.4.1", 10 | "react-dom": "15.4.1" 11 | }, 12 | "scripts": { 13 | "start": "react-scripts start", 14 | "build": "react-scripts build", 15 | "test": "react-scripts test --env=jsdom", 16 | "eject": "react-scripts eject" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Github.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | const urlForUsername = username => 4 | `https://api.github.com/users/${username}` 5 | 6 | class GitHub extends Component { 7 | constructor(props) { 8 | super(props) 9 | this.state = { 10 | requestFailed: false 11 | } 12 | } 13 | 14 | componentDidMount() { 15 | fetch(urlForUsername(this.props.username)) 16 | .then(response => { 17 | if (!response.ok) { 18 | throw Error("Network request failed") 19 | } 20 | 21 | return response 22 | }) 23 | .then(d => d.json()) 24 | .then(d => { 25 | this.setState({ 26 | githubData: d 27 | }) 28 | }, () => { 29 | this.setState({ 30 | requestFailed: true 31 | }) 32 | }) 33 | } 34 | 35 | render() { 36 | 37 | if (this.state.requestFailed) return

Failed!

38 | if (!this.state.githubData) return

Loading...

39 | return ( 40 |
41 |

{this.state.githubData.name}

42 |
43 | ) 44 | } 45 | } 46 | 47 | export default GitHub; 48 | 49 | 50 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | React App 17 | 18 | 19 |
20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). 2 | 3 | Below you will find some information on how to perform common tasks.
4 | 5 | ## Folder Structure 6 | 7 | After creation, your project should look like this: 8 | 9 | ``` 10 | my-app/ 11 | README.md 12 | node_modules/ 13 | package.json 14 | public/ 15 | index.html 16 | favicon.ico 17 | src/ 18 | App.css 19 | App.js 20 | App.test.js 21 | index.css 22 | index.js 23 | logo.svg 24 | ``` 25 | 26 | For the project to build, **these files must exist with exact filenames**: 27 | 28 | * `public/index.html` is the page template; 29 | * `src/index.js` is the JavaScript entry point. 30 | 31 | You can delete or rename the other files. 32 | 33 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.
34 | You need to **put any JS and CSS files inside `src`**, or Webpack won’t see them. 35 | 36 | Only files inside `public` can be used from `public/index.html`.
37 | Read instructions below for using assets from JavaScript and HTML. 38 | 39 | You can, however, create more top-level directories.
40 | They will not be included in the production build so you can use them for things like documentation. 41 | 42 | ## Available Scripts 43 | 44 | In the project directory, you can run: 45 | 46 | ### `npm start` 47 | 48 | Runs the app in the development mode.
49 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 50 | 51 | The page will reload if you make edits.
52 | You will also see any lint errors in the console. 53 | 54 | ### `npm test` 55 | 56 | Launches the test runner in the interactive watch mode.
57 | See the section about [running tests](#running-tests) for more information. 58 | 59 | ### `npm run build` 60 | 61 | Builds the app for production to the `build` folder.
62 | It correctly bundles React in production mode and optimizes the build for the best performance. 63 | 64 | The build is minified and the filenames include the hashes.
65 | Your app is ready to be deployed! 66 | 67 | ### `npm run eject` 68 | 69 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 70 | 71 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 72 | 73 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 74 | 75 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 76 | --------------------------------------------------------------------------------