This is the code for the crash course on YouTube
# Install dependencies
npm install
# Serve on localhost:3000
npm start
# Build for production
npm run build
React crash course files
How can you make a login page in this code?
After installing create-react-app, uuid, axios and react-router, I loaded the code in this repo and got a compile error in app.js. To fix the problem, I commented out the following:
import uuid from 'uuid';
res.data.id = uuid.v4();
in the addTodo method
On start with provided data, checkboxes are all unchecked but some of items are completed.
IMO there should be :
checked={this.props.todo.completed}
in line 19 in TodoItems.jsx
Hey,
First of all nice work with the videos on youtube. While watching your video I noticed that the markComplete
function is mutating the original state.
Line 23 in e07f0d8
Can be easily spotted with this example:
const todos = [{
id: 1, title: 'Learn React', completed: false
}, {
id: 2, title: 'Mutate state', completed: false
}];
const newState = todos.map(todo => {
if (todo.id === 2) {
todo.completed = !todo.completed;
}
return todo;
});
Hello! Importing is not working for uuid. It says :
Failed to compile.
./src/App.js
Attempted import error: 'uuid' does not contain a default export (imported as 'uuid').
But this is working :
const uuid = require('uuid');
Why it is showing error?
Hello Brad, first thanks for the great tutorial crash course, but the final code has some issues about the add new todo process. The new todos had same ids of '201', in my researchs i've found that this is a http code related. Searching in the comments i've found a fix from a user "David Ernest"
(His channel). The fix is listed below:
In App.js, at axios.post '.then' for appTodo change to this:
.then(res => {
res.data.id = uuid(); //or uuid.v4()
this.setState({ todos: [...this.state.todos, res.data] });
});
This should make your code work because this manually overwriting the id property that comes back from the JSON Placeholder API, as the Youtube user said!
Hope this help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.