GithubHelp home page GithubHelp logo

taniarascia / react-tutorial Goto Github PK

View Code? Open in Web Editor NEW
734.0 734.0 412.0 1.14 MB

A walkthrough of basic React concepts.

Home Page: https://taniarascia.github.io/react-tutorial/

HTML 1.53% JavaScript 23.08% CSS 75.38%
create-react-app javascript js learning library react tutorial web-development

react-tutorial's Introduction

React Tutorial

Learn the fundamentals of React including simple and class components, state, props, and submitting form data.

Purpose

  • Learn about essential React concepts and related terms, such as Babel, Webpack, JSX, components, props, state, and lifecycle.
  • Build a very simple React app that demonstrates the above concepts.

Author

License

This project is open source and available under the MIT License.

react-tutorial's People

Contributors

alexilyaev avatar dependabot[bot] avatar samkacer avatar taniarascia avatar webdandev avatar

Stargazers

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

Watchers

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

react-tutorial's Issues

Updating Blog

I've started learning React from blog, and while it's extremely well written, but i did face one issue.

In State section, you used the following code

image

where as, it should have been

<div className="container"> <Table characterData={this.state.characters} removeCharacter={this.removeCharacter} /> </div>

Otherwise, "characters" isn't recognized by our "Table" element.

image

React might have been updated since then, due to which this error/issue is coming now.

Resolution

So, basically, the blog does mention that we need to add
"const { characters } = this.state". This line kept skipping me eyes.

Why React?

You have answered What is React? But Why should I adopt React? Why was it invented? What problem does it solve? This will be useful info. Thx

'characters' is not defined

I get this error when adding the removeCharacter method to the App component and I can't figure out what's wrong, please help.

./src/App.js
  Line 39:31:  'characters' is not defined  no-undef

Search for the keywords to learn more about each error.
class App extends Component {
  state = {
    characters: [
      {
          name: 'Charlie',
          job: 'Janitor'
      },
      {
          name: 'Mac',
          job: 'Bouncer'
      },
      {
          name: 'Dee',
          job: 'Aspiring actress'
      },
      {
          name: 'Dennis',
          job: 'Bartender'
      }
  ]
  }

  removeCharacter = (index) => {
    const {characters} = this.state
  
    this.setState({
      characters: characters.filter((character, i) => {
        return i !== index
      }),
    })
  }

  render () {
    return (
      <div className='container'>
        <Table characterData={characters} removeCharacter={this.removeCharacter} />
      </div>
    )
  }
}

Alternative approach

In my App.js I have the method to handle adding a new user (with name and job fields)

    addCharacter = (name, job) => {
      this.setState(
        {
          characters: [...this.state.characters, {name, job}]
        }
      );
    }

And I use the functional Form component :

const Form = (props) => {
  return (
    <form>
      <input name='name' />
      <input name='job' />
      <button type='button' onClick={() => {
        props.addCharacter(
          // use any preferred approach to reference the value in need
          document.forms[0].elements.name.value,
          document.forms[0].elements.job.value
        )
        }}>
        Add
      </button>
    </form>
  )
}

Since your source code is drastically different ( it has a bit more lines and it's kind of hard to easily comprehend for me yet), can you point disadvantages of the way I approached it ( if any ) ?

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.