Skip to content

Why do the samples contain 'Math.random()'? #1754

Answered by williaster
onionhammer asked this question in Q&A
Discussion options

You must be logged in to vote

From the docs https://airbnb.io/visx/docs/threshold#Threshold_id

id for this threshold. If not set, multiple Threshold's on a page may conflict and interfere with each other.

thresholds use clip-paths which require ids. in examples, it doesn't matter if this is random. in your application you could consider using a unique id that is stable across renders. a simple solution (that would arguably demonstrate better react practices) would be to memoize this value with useMemo/useRef.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@onionhammer
Comment options

Answer selected by onionhammer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants