0

I am getting error in my console:
Below is the code of content.js which displays everything clearly but will the warning give any problem on rendering when my web app becomes complex. Screenshot: enter image description here

content.js file :

class Content extends Component {
    constructor(props){
        super(props);
        this.state = {
            matches:[],
            loading:true
        };
    }

    componentDidMount(){
        fetch('api/matches')
        .then(res => res.json())
        .then(res => {
      console.log(res)
      this.setState({
        matches:res,
        loading:false
      })
    })
    }

    render() {
        if (this.state.loading) {
            return <div>>Loading...</div>
        }

    return (
      <div>
          <div class="row">

            <div class="col-lg-3">
                <div id="one">
                    <p class="match">Match {this.state.matches[0].id}</p>
                    <p><h4>{this.state.matches[0].team1}</h4></p>
                    <p>VS</p>
                    <p><h4>{this.state.matches[0].team2}</h4></p>                  <====  LINE   39
                    <div class="winner">
                        <h3>Winner</h3>
                        <h4>{this.state.matches[0].winner}</h4>
                    </div>
                    <div class="stats">
                    <button type="button" class="btn btn-primary">View Stats</button>
                    </div>
                </div>
            </div>
          </div>
      </div>
    );
  }
}

export default Content;
11
  • <p>{this.state.matches[0].team1}</p> Commented Jan 24, 2018 at 14:52
  • @stack26 Should I remove <h4> so then should I style it later as I want text size to be large. Commented Jan 24, 2018 at 14:54
  • yes exactly !! You have to style is differently giving a separate className Commented Jan 24, 2018 at 14:58
  • 1
    Since h4 provide semantic benefits (for SEO) whereas styling the p only gives a visual differences, it would be better to use the h4 Commented Jan 24, 2018 at 15:02
  • 1
    i am sorry , it allows but will throw warning when h4 is used inside inside p. the same thing happens when you use p as the child of tbody. Commented Jan 24, 2018 at 15:07

1 Answer 1

1

According to this document document.Either you remove h4 tag or remove p tag outside it.

<p className="your_class">{this.state.matches[0].team1}</p>

or you can do it like this

<h4>{this.state.matches[0].team1}</h4>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.