最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - How to make if statement in react plugin?

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论