Commands and code used to create my first React app during training.
- Create React App - source coude and tool usefull for creating app in React.js
- Artur Chyży repository
- Pragmatists TDD Todos React app
npm install -g create-react-app
create-react-app my-app
cd my-app/
npm start
npm install --save-dev enzyme enzyme-adapter-react-16 react-test-renderer jest-cli jest-enzyme
npm i @types/jest @types/enzyme @types/expect
Fake Online REST API for Testing and Prototyping: JSONPlaceholder
npm install -g json-server
json-server http://jsonplaceholder.typicode.com/db --port 3001
npm install --save axios
Przykład pobrania danych:
axios.get('http://localhost:3001/todos')
.then(response => response.data)
.then(data => {
this.setState({
todos: data
});
})
.catch();
Przykład dodania danych do serwera:
axios.post('http://localhost:3001/todos', todo)
.then(() => this.fetchData());
npm install --save react-router react-router-dom