Create a React Component help

Create a React Component help
0.0 0

#1

Tell us what’s happening:

I am facing an error while executing this code. And the error is “The h1 header should contain the string Hello React!.” but I have already used a String in H1 tag. what is going wrong…?

I have also tried passing state to the h1 tag by storing string value in the state. but still its showing an error.

the challenge asked for 3 things… 1st is - The React component should return a div element. (completed)
2nd- The returned div should render an h1 header within it. (completed)

3rd- The h1 header should contain the string Hello React! (not completed)

Your code so far



class MyComponent extends React.Component {
  constructor(props) {
    super(props);
   
  }
  render() {
    // change code below this line
    return(
      <div>
        <h1>  'Hello React!  </h1>
      </div>
    );


    // change code above this line
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/create-a-react-component


#2

I did mine the same as yours but without extra spaces and it worked. Try removing the spaces before and after the hello sentence.


#3
<h1>  'Hello React!  </h1>

This is same as " 'Hello React! " when treated as literal string. It is true the string still contains "Hello React!", but it seems like the test is requires the exact match.


#4

But why does those extra space matters…?


#5

Its just typing mistake , I wrote exact match but still it doesn’t seems too work.


#6

pls post your newest code. The extra spaces matter because the checking program is written by a human being and sometimes makes mistakes.


#7

Thank You so much for the help, It worked…