Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

Describe your changes

Migrate the countdown component from class-based to functional.

Testing Plan

  • No logical changes, no tests required.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@lukasmasuch lukasmasuch marked this pull request as ready for review October 25, 2024 05:31
@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR impact:internal PR changes only affect internal code change:refactor PR contains code refactoring without behavior change labels Oct 25, 2024
public static defaultProps: Partial<Props> = {
endCallback: () => {},
}
const Countdown: React.FC<Props> = ({ countdown, endCallback = () => {} }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: instead of the defining a default function that does not do anything, we could just have it undefined and check for it here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made it a required prop again which should solve this as well.

const { countdown } = this.state
const { endCallback } = this.props
const newCountdown = countdown - 1
const onAnimationEnd = (): void => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you know why onAnimationEnd was an async function before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, not sure. But I changed it back to async.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have just had a look at the MDN web docs and it does not mention asynchronicity: https://developer.mozilla.org/en-US/docs/Web/API/Element/animationend_event
So in this case we should probably remove it to avoid confusion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oki, I removed it again 👍

@lukasmasuch lukasmasuch enabled auto-merge (squash) October 29, 2024 06:22
@lukasmasuch lukasmasuch merged commit 75e4d69 into develop Oct 29, 2024
edegp pushed a commit to edegp/streamlit that referenced this pull request Jan 19, 2025
## Describe your changes

Migrate the countdown component from class-based to functional. 

## Testing Plan

- No logical changes, no tests required.

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.

---------

Co-authored-by: Lukas Masuch <[email protected]>
@lukasmasuch lukasmasuch deleted the refactor/modernize-countdown-component branch March 5, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:internal PR changes only affect internal code security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants