Why do the samples contain 'Math.random()'? #1754
-
Just saw this pop up in sonarcloud for me, and was wondering what the reasoning was for random key/ids to be added in the samples Is this to force re-rendering? Does it break without random keys? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
From the docs https://airbnb.io/visx/docs/threshold#Threshold_id
thresholds use |
Beta Was this translation helpful? Give feedback.
From the docs https://airbnb.io/visx/docs/threshold#Threshold_id
thresholds use
clip-path
s which requireid
s. 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 withuseMemo/useRef
.