Coder Social home page Coder Social logo

phone-directory's Introduction

What Did I Do

  • Component Tree

  • Form Component:

    • state = {name: "",phone: "",};

    • onChange Function: Maps the entered expressions to the same element in state.

    • onSubmit Function: It puts the data in the form to addContact in the props, then cleans the data in the state

  • List Component:

    Filters and lists data from props by data from input

  • Contact Component:

    It distributes props from App.js to related components.

  • App component:

    Our data is here.

    We wrote the AddContact function used by the form component here, because they are at the same level as the component we want to list the data with, and because react adopts the one way data binding philosophy

  • I create a stateless component
    Contacts componenti

     const Contacts = (props) => (
     <div>
     	<List contacts={props.contacts} />
     	<Form addContact={props.addContact} />
     </div>
     );
    
     export default Contacts;
  • I use PropTypes library for data integrity and reliability

     Contacts.propTypes = {
     	contacts: PropTypes.array.isRequired,
     	addContact: PropTypes.func,
     };
  • I use two different function bind method:

    • Bind in constructor (in Form.js):
       constructor() {
       	super();
       	this.onChange = this.onChange.bind(this);
       }
      
       onChange(e) {
       	this.setState({ 
       		[e.target.name]: e.target.value 
       	});
       }
    • Using as arrow function (in List.js):
       onChangeFilterText = (e) => {
       	this.setState({ filterText: e.target.value });
       };

Installation

In the project directory, you can run:

npm install

Downloads to all dependency packages

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.

phone-directory's People

Contributors

mustafacelal avatar

Watchers

 avatar

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.