Git Product home page Git Product logo

_react's Introduction

Basics of

React

This repository contains starter projects using React, all projects are primarily focused on understanding how React works and getting familier with the basic functionalities.

  • Project Structure
-| project directory | 
    -| node_modules |
    -| public |
    -| src |
        -| index.js |
        -| App.js |
        -| Components |
            -| Header.js |
            -| Footer.js |
    -| package-lock.json |
    -| package.json |

Render

  • To render this, simply use ReactDOM.render():
ReactDOM.render(
    <Welcome name={ 'John Doe' }/>,
    document.getElementById( 'root' )
);

Components

  • What are components?
  • Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
  • Two types of Components
  • Function
  • Class

We'll focus on function components ( we don't use class components much anymore, we use hooks instead ). We'll take a quick look at class components and move forward.

  • Class Component
class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}
  • Here's an example of Function Component:
function Welcome( props ) {
    return <h1>Hello, { props.name }</h1>;
}

Props

  • What are props?
/* pass props like this */
const element = <Welcome name="John" />;

/* and access like this */
function Welcome( props ) {
    return <h1>Hello, { props.name }</h1>;
}

State

  • What is state?
  • Conceptually, states are like javascript objects that holds

_react's People

Contributors

sneharupmukherjee 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.