Giter VIP home page Giter VIP logo

react-todo's Introduction

Demo Project for CRUD operations in Reactjs.

To run the project

Clone this repository and cd into root project and type npm start to run the server.

Open http://localhost:3000 to view it in the browser.

react-todo's People

Contributors

zafar-saleem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-todo's Issues

Minor clarity issues

Hi Zafar-

Thanks so much for writing this tutorial...it was very helpful. The syntax of your callback methods seems a bit strange in a few places. (If you deliberately did it this way for some reason, please forgive me.)

  1. In the onDeleteHandle method, you're using an if/then where it's not really necessary:

this.setState({ mockData: this.state.mockData.filter(item => { if (item.id !== id) { return item; } }) }); }

It would be much clearer to write

this.setState({ mockData: this.state.mockData.filter(item => { return item.id !== id; }) });

  1. In some of the event handlers, you're adding an extra return statement--

this.setState({ mockData: this.state.mockData.map(item => { if (item.id === this.state.id) { item['title'] = event.target.updatedItem.value; return item; } return item; }) });

--where, again, it's not really necessary:

this.setState({ mockData: this.state.mockData.map(item => { if (item.id === this.state.id) { item.title = e.target.updatedItem.value; } return item; }) });

I realize these are minor issues but they threw me for a bit of a loop when I was doing the tutorial.

onCompleteHandle Needs A .bind And An Additional Argument

Hi again-
In the render method of the Todo component, the line
<button onClick={this.onCompleteHandle}>Complete</button>
won't work as written. Without a .bind, the method can't update {this.state} and there's no reference to which entry is supposed to be marked complete.

So onCompleteHandle needs to have a .bind and to also be supplied item.id as an argument, as below:
<button onClick={this.onCompleteHandle.bind(this, item.id)}>Complete</button>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.