Ask for feedback for Front End Project 1 Quote Generator with React

Hi there,

I completed project 1 of the Front End library using React only, and I wanted to get some feedback on the use of React, mainly the logic of it, and if components are created correctly.

Here is the code:

import * as React from "";
import * as ReactDOM from "";

const api_link = ''

class Quote extends React.Component{
    this.state = {
      msg: [],
      randomIndex: Math.floor(Math.random()),
      quote: '',
      author: ''
    this.changeQuote = this.changeQuote.bind(this);
      randomIndex: Math.floor(Math.random()*this.state.msg.length),
      quote: this.state.msg[this.state.randomIndex]['quote'],
      author: this.state.msg[this.state.randomIndex]['author']
  componentDidMount() {
    // = "red"
    fetch(api_link, {
      headers : { 
        'Accept': 'application/json'
      .then(response => response.json())
      .then(data => this.setState(
                                   {randomIndex: Math.floor(Math.random() * data.quotes.length),
                                   quote: data.quotes[this.state.randomIndex]['quote'],
                                   author: data.quotes[this.state.randomIndex]['author']

  render() {
    var twitterUrl = "" + encodeURIComponent('"' + this.state.quote + '" -' +
    <div id="wrapper">
        <div id="quote-box">
          <h3 id="text">{this.state.quote}</h3>
          <p id="author">- {}</p>
          <button id="new-quote" onClick = {this.changeQuote}>Change Quote</button>
          <a id="tweet-quote" href={twitterUrl}>Tweet</a>

ReactDOM.render(<Quote/>, document.getElementById('root'));


Can you give us a link to a working version?

Yep here it is!


So ya, you did enough to pass all the tests but I wouldn’t say you really completed the project (feels a bit unfinished to me). If all you care about is the JS code then I guess you should be content with what you have.

I will point out that the only heading you have on the page is an h3. Generally you want to start with an h1. What was the reason you chose an h3?

Also, this feels like a <blockquote> would be appropriate here. Check out how MDN marks up a blockquote.

Thanks Bruce!

For sure it is not finished, I wanted to get the logic React part right first and then focus on the design portion of it. Thanks for the blockquote and H1 suggestion!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.