Giter Club home page Giter Club logo

checkpoint-react's Introduction

React Intro Checkpoint

React

Question #1

Edit the snippet below. Pass default properties into the App component, named title & author. Choose your own values to pass down, make sure they're valid.

// assume necessary modules/components are already imported above
ReactDOM.render(
  <App title={""} author={""}/>,
  document.getElementById('root')
);

Question #2

Edit the snippet below. Display the passed in properties title & author in an appropriate part of the template.

// assume Component is imported above
class App extends Component {
  render () {
    return (
      <div>
        <h1>Welcome to{this.props.title}</h1>
        <footer>This site is designed by{this.props.author}</footer>
      </div>
    )
  }
}
// assume we are exporting correctly below

Question #3

Given a component named Post located in /js/components/Post/Post.js. Edit the below code snippet to import the Post component and render it as a child within Main's display (Main is located in /js/components/Main/Main.js).

// assume Component and Comments are imported above

import Post from `./js/components/Main/Main.js`

class Main extends Component {
  render () {
    return (
      <div>
        <Comments: />
        <Comment body={this.props.body[0]} />
      </div>
    );
  }
}
// assume we are exporting correctly below

Question #4

Products receives a property called listing containing an array of objects. Each object contains a key for name (a string) and price (a number). Edit the below code snippet to render a list of Product components that take name and price as incoming properties.

// assume Component and Product are imported above
class Products extends Component {
  constructor (props) {
    super()
    this.state={}

    )
  }

  render () {
    return (
      <div key={name} className="Products">
      <div key={price} className="Products">



      <div/>
    )
  }
}

const Product {
  return
}


// assume we are exporting correctly below

Question #5

In the code snippet below we want text entered into the input field to be displayed inside the <p>. Set up the state variable and add logic to update it as characters are typed.

// assume all necessary components are imported above
class App extends Component {
  render() {
    return (
      <div>
        <form>
          <label>Input: </label>
          <input type="text" />
        </form>
        <p>Message: { this.state.message } "text"</p>
      </div>
    );
  }
}
// assume we are exporting correctly below

React-Router

Question #6

You are in your terminal, inside of an existing react application. Enter the command(s) needed to add React Router to the current app.

# your command(s) here

npm install --save React Router

Question #7

Edit the following code snippet. Add the Router component, and rewrite the rest of this snippet to incorporate Links and matching Routes. Each route will render a component matching it's link text (without spaces).

// assume all necessary components are imported above
class App extends Component {
  render () {
    return (
    <Router>
      <div>
        <h1>Welcome to My shopping site</h1>
        <nav>
          <a href="/">Home</a>
          <a href="/products">Products</a>
          <a href="/cart">Shopping Cart</a>
        </nav>
        <main/>
        <footer>This site is designed by us</footer>
      </div>
      </Router>
    )
  }
}
// assume we are exporting correctly below

Question #8

Edit the code snippet below. Only once when the component has loaded, make an AJAX GET request to 'http://api.example.com/info' and display the results in the provided <div>.

// assume all necessary components are imported above

import $ from 'jQuery'

class App extends Component {
  // assume the constructor is complete
  render () {
    return (
      <div>
        <h1>Results</h1>
        <div>{ this.state.results }</div>
      </div>
    )
  }
}

const term= query.replace(/\s, "+ ")
// assume we are exporting correctly below

checkpoint-react's People

Contributors

juancgarcia avatar lgmusic24 avatar

Watchers

James Cloos 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.