-1
import React, {Component} from 'react';
import { dumpLogs } from './Utils.js';



class RecCard extends Component {
     state = {
         quantity: null
     }

     incrementNumber = () => {
         this.setState((prevState, prevProp) => {
             return {quantity : prevState.quantity +1}
         });
     }

     decrementNumber = () => {
         this.setState((prevState, prevProp) => {
            return {quantity : prevState.quantity -1}
            
         });
     }

    render() {
    dumpLogs(this.props);
    return(
        <div>
            <h3>{this.props.title}</h3>
            <h5>{this.props.price} PLN</h5>
            <span>{this.state.quantity}</span> &nbsp; 
            <span className='hidden'>{this.props.price * this.state.quantity}</span> 
            <button onClick={this.incrementNumber}>+</button>
            <button onClick={this.decrementNumber} disabled={this.state.quantity <= null}>-
            </button>
        </div>

    )}
        
}



export default RecCard; 
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • You can try using useContext take a look [here](https://stackoverflow.com/questions/50502664/how-to-update-the-context-value-in-a-provider-from-the-consumer) – Mainumbi Sep 06 '22 at 15:27

1 Answers1

0

From what i can see, this is (most likely) a duplicate of This Post.
You should be able to export values using the export keyword. By assigning your this.props.price * this.state.quantity to a local variable and then exporting said variable (using export MaxPrice, or whatever you called that variable).

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Wadafacc
  • 3
  • 2