├── public ├── favicon.ico └── index.html ├── src ├── assets │ ├── index.css │ ├── App.css │ └── logo.svg ├── index.js ├── tests │ └── App.test.js └── components │ ├── User.js │ ├── UserForm.js │ ├── UserList.js │ └── App.js ├── .gitignore ├── package.json └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miguelghz/Intro-ReactJS/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/assets/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './components/App'; 4 | import './assets/index.css'; 5 | 6 | 7 | ReactDOM.render( 8 | , 9 | document.getElementById('root') 10 | ); 11 | -------------------------------------------------------------------------------- /src/tests/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 | -------------------------------------------------------------------------------- /src/components/User.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | class User extends Component { 4 | render () { 5 | return ( 6 |
  • 7 | {this.props.name} - {this.props.email} 8 |
  • 9 | ); 10 | } 11 | } 12 | 13 | export default User; -------------------------------------------------------------------------------- /.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 | yarn-debug.log* 17 | yarn-error.log* 18 | 19 | -------------------------------------------------------------------------------- /src/components/UserForm.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | 3 | export default class UserForm extends Component{ 4 | render(){ 5 | return ( 6 |
    7 | 8 | 9 | 10 |
    11 | ); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/assets/App.css: -------------------------------------------------------------------------------- 1 | li { 2 | list-style: none; 3 | } 4 | 5 | .App { 6 | text-align: center; 7 | } 8 | 9 | .App-logo { 10 | animation: App-logo-spin infinite 20s linear; 11 | height: 80px; 12 | } 13 | 14 | .App-header { 15 | background-color: #222; 16 | height: 150px; 17 | padding: 20px; 18 | color: white; 19 | } 20 | 21 | .App-intro { 22 | font-size: large; 23 | } 24 | 25 | @keyframes App-logo-spin { 26 | from { transform: rotate(0deg); } 27 | to { transform: rotate(360deg); } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Intro-ReactJS", 3 | "homepage": "https://miguelgomez.io/demos/intro-reactjs", 4 | "version": "0.1.0", 5 | "private": true, 6 | "devDependencies": { 7 | "react-scripts": "0.9.0" 8 | }, 9 | "dependencies": { 10 | "react": "^15.4.2", 11 | "react-dom": "^15.4.2" 12 | }, 13 | "scripts": { 14 | "start": "react-scripts start", 15 | "build": "react-scripts build", 16 | "test": "react-scripts test --env=jsdom", 17 | "eject": "react-scripts eject" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/components/UserList.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import User from '../components/User' 3 | 4 | class UserList extends Component { 5 | render () { 6 | return ( 7 | 18 | ); 19 | } 20 | } 21 | 22 | export default UserList; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Intro-ReactJS 2 | 3 | 4 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). 5 | 6 | For the project to build, **these files must exist with exact filenames**: 7 | 8 | * `public/index.html` is the page template; 9 | * `src/index.js` is the JavaScript entry point. 10 | 11 | ## Available Scripts 12 | 13 | In the project directory, you can run: 14 | 15 | ### `npm start` 16 | 17 | Runs the app in the development mode.
    18 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 19 | 20 | The page will reload if you make edits.
    21 | You will also see any lint errors in the console. 22 | 23 | ### `npm test` 24 | 25 | Launches the test runner in the interactive watch mode.
    26 | 27 | ### `npm run build` 28 | 29 | Builds the app for production to the `build` folder.
    30 | 31 | ## Blog article 32 | https://miguelgomez.io/react/tutorial-react-js-introduccion/ 33 | 34 | ## Demo 35 | https://miguelgomez.io/demos/intro-reactjs/ -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | React App 17 | 18 | 19 |
    20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/components/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import UserList from '../components/UserList'; 3 | import UserForm from '../components/UserForm'; 4 | import logo from '../assets/logo.svg'; 5 | import '../assets/App.css'; 6 | 7 | class App extends Component { 8 | constructor() { 9 | super(); 10 | this.state = { 11 | users: [ 12 | {id: 1, name: "miguel", email: "miguelghz@miguelgomez.io"}, 13 | {id: 2, name: "test", email: "test@test.es"} 14 | ] 15 | }; 16 | } 17 | 18 | handleOnAddUser (event) { 19 | event.preventDefault(); 20 | let user = { 21 | name: event.target.name.value, 22 | email: event.target.email.value 23 | }; 24 | this.setState({ 25 | users: this.state.users.concat([user]) 26 | }); 27 | } 28 | 29 | render() { 30 | console.log(this.state.users); 31 | return ( 32 |
    33 |
    34 | logo 35 |

    Bienvenido a React

    36 |
    37 |
    38 |

    Añade usuarios

    39 | 40 | 41 |
    42 |
    43 | ); 44 | } 45 | } 46 | 47 | export default App; -------------------------------------------------------------------------------- /src/assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | --------------------------------------------------------------------------------