Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react1-week2/gizem #282

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

react1-week2/gizem #282

wants to merge 18 commits into from

Conversation

GizemSavci
Copy link

Demo.mov

@github-actions github-actions bot changed the title React1 week2/gizem react1-week2/gizem Apr 2, 2024
Copy link

@NVedsted NVedsted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 🌟 Was a joy to setup your app and see it in action. 😄 Feel free to reach out if you have any questions. 🙂


useEffect(()=>{
const timer = setInterval(()=>{
setSeconds(prevSeconds => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work with the split into minutes and seconds! 🎉 Much more appealing to look at.

There is a small issue with the updater function for seconds: it is not pure! It has a side-effect since it calls setMinutes. You might have seen when running in development mode, that your minute counter increments twice every time 60 seconds pass. This is due to it running it strict mode where it runs functions supposed to be pure twice to provoke purity issues during development. You can read more here.

Can you think of a way to do this with only one simple state and not two? Then it becomes a lot easier to manager. 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created one state elapsedTime. Can you check from my commits:Fix Timer bug? Thank you for helping with this bug🙏

);
}

TodoItem.propTypes = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice to set some types and the like so we can catch pesky type errors and missing props! 👍 Deadline, Task, and TodoList are missing them though. They are not required, but consistency is key! 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you🙏 I just used PropTypes for Deadline, Task and TodoList.

}

const handleRemoveClick = () => {
removeTodo(todo.id);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of callback patterns! ⭐ I would suggest going with the convention of onSomeAction to make it clear this is akin to listening to an event in the component.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but React documentation has examples with handleStuff. Sorry, I couldn't understand what to do🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants