These are chat archives for FreeCodeCamp/Help

25th
Feb 2019
kinopotato
@kinopotato
Feb 25 03:22
happy coding!
Kranti Nebhwani
@darkphotonKN
Feb 25 03:39
Hey guys, I have this react project I'm working on and I'm using a mobile menu from a third party download, but it seems like it's menu open / close and animation triggers require the window to be loaded. The code for it's mobile menu is here: https://codeshare.io/GAWBAx.
So when I reload pages or enter a certain page of my react project and the page loads the menu works fine. if I click on a a link which changes the page via react router it doesn't work however. Did some research seems like using react router prevents it skips window loading or something so the code doesn't fire.
However even if I remove window.onload for the code in the file or use it inside my react components directly it seems to not fire on route change too.. Only on refresh or actual page links (a tags with no routing).
Does anyone have a way to get it to work, have a look at the code? Becuase even if it doesn't have window.onload it's still not firing
zootechdrum
@zootechdrum
Feb 25 05:22
hello everyone
I need some help
startCountDown = () => {
  //checks if time is 0 and if break is false to change time === to breaklength
  if(this.state.time === 0 && this.state.breakStatus === false){
     this.setState({
       breakStatus: !this.state.breakStatus,
       time:this.state.breakLength
    })
    //Below if statement checks if timer time should be set to time
    }else if(this.state.time === 0 && this.state.breakStatus === true){
      console.log("reached")
       this.setState({
         breakStatus: !this.state.breakStatus,
         time:this.state.setTime
       })
     }

 if(this.state.timer === true){
     this.setState ({
       time:this.state.time - 1
     })
  }
}
The above is for my pomo clock the issue I am having is when it starts to cont down it shows 1 less than what state actually is . How can I display the number held in state first and then subtract by on
here is the full link to my codepen https://codepen.io/zootechdrum/pen/maZKOQ?editors=0011
zootechdrum
@zootechdrum
Feb 25 06:11
I kinda figured it out by adding one. If any of you have a better solution please let me know. Here is what I have so far
    }
}

//Clock starts to countdown
startCountDown = () => {
  //checks if time is 0 and if break is false to change time === to breaklength
  if(this.state.time === 0 && this.state.breakStatus === false){
     this.setState({
       breakStatus: !this.state.breakStatus,
       //added 1 to show the acutal number held in state
       //if you do not add 1 it will subtract 1 from state to quickly
       time:this.state.breakLength + 1
    })
    //Below if statement checks if timer time should be set to time
    }else if(this.state.time === 0 && this.state.breakStatus === true){
      console.log("reached")
       this.setState({
         breakStatus: !this.state.breakStatus,
       //added 1 to show the acutal number held in state
       //if you do not add 1 it will subtract 1 from state to quickly
         time:this.state.setTime + 1
       })
     }

 if(this.state.timer === true){
     this.setState ({
       time:this.state.time - 1
     })
  }
}
Manish Giri
@Manish-Giri
Feb 25 07:15
@zootechdrum you can use prevState as a parameter in your setState func
that way you won't need to +1
Kranti Nebhwani
@darkphotonKN
Feb 25 08:40
Any ideas on how to run or package my setup after I added babel and webpack that utilized the babel in a project that I would use ES6+ js with? I went through a tutorial to set up babel and webpack but no intrsutctions in the end on how to actually run it so that the webpack bundles or compiles my code...
Im thinking I have to add a command script in package.json but I'm not sure what command
Christopher McCormack
@cmccormack
Feb 25 15:28
@darkphotonKN many of use use a script in package.json to run webpack against the root directory, which often has the webpack.config.js file. something like
  "scripts": {
    "build": "webpack",
    ...
Xarri Jorge
@xarrijorge
Feb 25 15:31
Hello folks, I have an idea for an open source project similar to polish.js but with more methods for native values. Anyone wanna join?
zootechdrum
@zootechdrum
Feb 25 16:47
@Manish-Giri didn't work
It still subtract - 1 to early
Smootimus
@Smootimus
Feb 25 17:49
:D
Niraj Nandish
@Nirajn2311
Feb 25 18:27
@Smootimus hey, how's it going?
Smootimus
@Smootimus
Feb 25 18:37
Ay, long time no see
Just finished up some JS stuff and about to ehad to math class
Niraj Nandish
@Nirajn2311
Feb 25 20:46
Nice, long time no see also
Gonna have my finals from this saturday
Smootimus
@Smootimus
Feb 25 22:21
Oh yeah? Finals are in a week or two for me @Nirajn2311
Not too far away