Skip to main content
added 175 characters in body
Source Link

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<10000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, [][wynik]);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

update:

I add dependence "wynik" but it not resolve my problem. Just count 2from 4 variables not all of them. I try without useEffect but then it make an error.

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<10000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, []);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<10000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, [wynik]);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

update:

I add dependence "wynik" but it not resolve my problem. Just count 2from 4 variables not all of them. I try without useEffect but then it make an error.

added 1 character in body
Source Link

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<1000wynik<10000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, []);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<1000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, []);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<10000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, []);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

deleted 381 characters in body; edited title
Source Link

how How to use react select/ inputsmake if statement in Wordpress block-editor (frontendreact plugin?

I created my firstCreate Guttenberg pluggin by react plugin and I have problem with my frontend. I test my code in sandbox code and work perfect. Here on Wordpress frontend I have problem but calculator appear but I haveMy problem with calculations. I can count just in render part of code something likeis that {param / params} I do not need to explain how it problematic iscannot use if statement.

My structure of code looks like that:

import React, {useState, useEffect} from 'react'
import ReactDOM from 'react-dom'
import "./frontend.scss"

const divsToUpdatepriceforextrashop = document.querySelectorAll parseFloat(".calculator")

divsToUpdateprops.forEach(function(divpriceextra) {
  const datapriceforegoodshop = JSON.parse(div.querySelector("pre").innerHTML)
  ReactDOM.renderparseFloat(<Calc {...data} />, div)
  div.classListprops.remove("calculator")
}pricegoood)
 
function Calc(props) {
const [param, setParam]priceforstandardshop = useStateparseFloat(""props.pricestandard);
const [params,const setParams]priceforsmallshop = useStateparseFloat(0props.73 pricesmall);
const sum = param / params;

returnReact.useEffect(
        <input 
          type="number"
          placeholder="how much you paid() for=> that"{
          value=if(wynik<20000){param}
          onChange={ (e) => setParamsetPrice(e.target.valuepriceforextrashop) };
        />
}
        <input if(wynik<15000){
          type="number"setPrice(priceforegoodshop);
          placeholder="How often you do it?"}
          value=if(wynik<1000){params }
          onChange={ (e) => setParamssetPrice(e.target.value priceforstandardshop) };
        />}
     <button onClick=if(wynik<5000){calc}>
          PoliczsetPrice(priceforsmallshop);
        </button>}

{sum}
 , []);
}

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

how to use react select/ inputs in Wordpress block-editor (frontend

I created my first react plugin and I have problem with my frontend. I test my code in sandbox code and work perfect. Here on Wordpress frontend I have problem but calculator appear but I have problem with calculations. I can count just in render part of code something like that {param / params} I do not need to explain how it problematic is.

My structure of code looks like that:

import React, {useState, useEffect} from 'react'
import ReactDOM from 'react-dom'
import "./frontend.scss"

const divsToUpdate = document.querySelectorAll(".calculator")

divsToUpdate.forEach(function(div) {
  const data = JSON.parse(div.querySelector("pre").innerHTML)
  ReactDOM.render(<Calc {...data} />, div)
  div.classList.remove("calculator")
})
 
function Calc(props) {
const [param, setParam] = useState("");
const [params, setParams] = useState(0.73 );
const sum = param / params;

return(
        <input 
          type="number"
          placeholder="how much you paid for that"
          value={param}
          onChange={ (e) => setParam(e.target.value) }
        />

        <input 
          type="number"
          placeholder="How often you do it?"
          value={params }
          onChange={ (e) => setParams(e.target.value ) }
        />
     <button onClick={calc}>
          Policz
        </button>

{sum}
 );
}

How to make if statement in react plugin?

I Create Guttenberg pluggin by react. My problem is that I cannot use if statement.

 const priceforextrashop =  parseFloat(props.priceextra)
 const priceforegoodshop = parseFloat(props.pricegoood)
 const priceforstandardshop = parseFloat(props.pricestandard)
 const priceforsmallshop = parseFloat(props.pricesmall)
   React.useEffect(() => {
     if(wynik<20000){
      setPrice(priceforextrashop);
    }
     if(wynik<15000){
      setPrice(priceforegoodshop);
    }
     if(wynik<1000){
      setPrice(priceforstandardshop);
    }
   if(wynik<5000){
    setPrice(priceforsmallshop);
  }

}, []);

props.prices reffer to attritubutes I add on editor-block side of plugin. The value work good, I exposed them on screen. problem is just with these if statement because always show the same value. I know that the if statement should work good because on editor-black side or in another scripts, I put the same if statement and it worked. Please indicate me answer.

added 611 characters in body; edited title
Source Link
Loading
Source Link
Loading