Hi all.
I deleted this as it was irrelevant and might confuse people.
My question is the last post .
Thanks
Hi all.
I deleted this as it was irrelevant and might confuse people.
My question is the last post .
Thanks
From your code:
defaultBreak : ++defaultState.defaultBreak, //should be defaultBreak : defaultState.defaultBreak - 1 , but it breaks
It should be
defaultBreak : state.defaultBreak + 1
You are still using the initial state object, leave it alone. Use the state
inside the reducer.
You are still mutating state in a lot of places. This is one of the hard parts of Redux, learning how to avoid state mutation. Again, my advice is to take some more time to learn Redux. Do some simple tutorials, then make some simple projects where you use Redux. After you have learned more about Redux, re-apply what you have learned to this project.
The way I see it, you are not making a 25 + 5 clock, you are learning about React and Redux. So focus on learning.
oh oke , I not do defaultState but state. Iāll try that.
Look you canāt brute force this. You are going to have to spend more time learning about Redux, there is just no way around it.
Remember itās just a tool. Some people hate Redux but they have to work with it because the project (their work) requires it. This project does absolutely not require Redux, so if you do want to use Redux, you are just going to have to learn more about it first.
Edit: BTW, I donāt mean you shouldnāt use this thread to ask for help, you totally should (please do). But it will be much better after you spend a little more time learning about the tools you are using.
I will, any particular tutorial that would be helpful for not changing state ? I off course read/did FCC tutorials, some youtube tutorials,etc, but itās probably limited.
I donāt particularly like the redux/react.org site.
Well, the Redux site is the official docs so you canāt really get closer to the source than that. I would suggest you read through the writing-reducers part at least. If you have not checked out the site lately it has been updated and is better than it used to be.
Dan Abramov has some free videos on egghead.io that gives a good introduction.
Programming with Mosh has a fairly comprehensive video on Redux which touches on some important concepts.
Again, you do not have to use Redux for this project.
If I was to ask you to write this app in just React do you think you would be able to do it? Do you understand normal state management in React well enough? Because if not, throwing Redux in the mix is not going to make it any easier.
Just as an aside, and not to pile more wood on the fire, but just as a friendly FYI.
I would suggest using a coding environment that is better geared to React and Redux. Check out CodeSandbox itās so much better for this kind of work and a lot more like working locally inside a real code editor. It has much better error handling and the starter React template is based on create-react-app.
Personally, I really do not like Codepen for React and I have seen it swallow errors that should result in the code failing to compile, the error handling/feedback is just very lacking on Codepen.
Thanks , I will look into codesandbox as well
Hi all.
So, Iāve made some changes to my code, but itās still not passing all tests.
These are the errors Iām getting:
Timer has not reached 00:00.
Timer has not reached 00:00.
Timer has not reached 00:00
Iāve also noticed that it takes forever to run the tests, and that there are several red times marked. I donāt know if that is a problem or not, or maybe itās because of these errors Iām getting?
Ignoring the audio right now as Iām not done with that yet.
iād just like to know if Iām on the right track, some hints or so
Thanks
You do not want to overwrite the state
, just return a new copy.
I would suggest you use the more common syntax of returning the state object with the old state spread in and whatever updates are needed.
Move the if logic out of the reducer into handler functions so the dispatch is only called if the condition is met.
case INCBREAK:
return {
...state,
defaultBreak: state.defaultBreak + 1
}
handleBreakIncrement = () => {
if(this.props.clock.defaultBreak < 60) {
this.props.breakIncrement()
}
}
onClick={this.handleBreakDecrement}
Thanks, those changes make total sense.
I did see it done somewhere state = object.assign() etc and then state was returned, but it does technically still overwrite state as itās assigning to state. thanks
I now only have more errors.
Timer has not reached 00:00. āSession\n25:00\nstart/pauseresetā
25 + 5 has started but time displayed is not changing: expected ā00ā to not equal ā00ā
Timer has not reached 00:00.
Timer has not reached 00:00.
None of these errors are making sense when I test the timer it seems to work correctly. Iām at a loss once again. Itās very hard to know how to fix it if donāt even see the errors.
Hope someone is willing to help , yet again !
itās almost as if thereās two timers running and thatās causing a problem, but iām sure thereās only one timerId set and cleared.
Iām hoping the problem is very minor at this point, and I can finish this project soon. Thanks
Iām at a loss still whatās causing the tests to fail.
Hope someone has some insight , just a clue with be very helpful
These are the errors now.
Default timer label was not properly reset : expected āBreak\n25:00\nstart/pauseresetā to equal āSession\n25:00\nstart/pauseresetā
25 + 5 clock has started but time displayed is not changing : expected 0 to be above 0 AssertionError: 25 + 5 clock has started but time displayed is not changing : expected 0 to be above 0
25 + 5 has started but time displayed is not changing: expected ā00ā to not equal ā00ā AssertionError: 25 + 5 has started but time displayed is not changing: expected ā00ā to not equal ā00ā
Timer has not reached 00:00. Error: Timer has not reached 00:00.
Timer has switched to Break time, but it didnāt start with the correct value.: expected 1 to equal 5
Timer has not reached 00:00.
It just doesnāt make sense the timer runs, the timer changes correctly , from what I see between sessions/breaks?
I just hate to waste so much time on this. Iām hoping someone is willing to take a look.
I know itās more errors than before, but I made changes that logically to me make sense, as there are anyway still errors either way , I leave the changes.
Thanks