mardi 30 mars 2021

TypeError: this.props.onIncrement is not a function

I,m totally new in react and try to create counter app but when i try to move counters component functionality to the main App.js i receive an error in counter component. I will be very thankful for help enter image description here

Counters component

import React, { Component } from 'react';
import Counter from './counter';
class Counters extends Component {
render() { 
    return (
    <div>
        <button 
        className="btn btn-primary btn-large m-2" 
        onClick={this.props.OnReset}
        >Reset
        </button>

       {this.props.counters.map(counter => (
       <Counter 
       key={counter.id} 
       onDelete ={this.props.OnDelete} 
       onIncrement ={this.props.OnIncrement}
       counter={counter}
       />
      ))}
    </div>
    );
}

}

render part from App.js

render(){
return (
  <React.Fragment>
    <NavBar/>
    <main className="container">
      <Counters
      counters={this.state.counters}
      onReset = {this.handleReset}
      onDelete ={this.handleDelete} 
      onIncrement ={this.handleIncrement}
      />
    </main>
  </React.Fragment>


);

}




Aucun commentaire:

Enregistrer un commentaire