-
Notifications
You must be signed in to change notification settings - Fork 731
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
breaking(responsive, xychart): require ResizeObserver or polyfill #1622
Conversation
742c3f7
to
c23212e
Compare
console.warn = console.error = function mockedConsole(message) { | ||
throw new Error(message); | ||
}; | ||
function mockedConsole(...args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was swallowing some messages so made it ...args
observe(el: Element): void; | ||
type ResizeObserverCallback = (entries: ResizeObserverEntry[], observer: ResizeObserver) => void; | ||
|
||
declare class ResizeObserver { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this definition to better match @juggle/resize-observer
and react-use-measure
@@ -42,5 +42,5 @@ module.exports = { | |||
testURL: 'http://localhost', | |||
timers: 'fake', | |||
verbose: false, | |||
testPathIgnorePatterns: ['<rootDir>/packages/visx-demo', '<rootDir>/packages/visx-visx'], | |||
testPathIgnorePatterns: ['<rootDir>/packages/visx-demo'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@visx/visx
tests were turned off 😱
Size Changes
View raw build statsPrevious (master){
"visx-annotation": {
"esm": 31002,
"lib": 43431
},
"visx-axis": {
"esm": 21861,
"lib": 26466
},
"visx-bounds": {
"esm": 2948,
"lib": 3371
},
"visx-brush": {
"esm": 54136,
"lib": 58297
},
"visx-chord": {
"esm": 3478,
"lib": 4691
},
"visx-clip-path": {
"esm": 4524,
"lib": 6062
},
"visx-curve": {
"esm": 323,
"lib": 1462
},
"visx-demo": {
"esm": 0,
"lib": 36504
},
"visx-drag": {
"esm": 12756,
"lib": 14402
},
"visx-event": {
"esm": 3878,
"lib": 5194
},
"visx-geo": {
"esm": 13515,
"lib": 16741
},
"visx-glyph": {
"esm": 15177,
"lib": 19992
},
"visx-gradient": {
"esm": 18202,
"lib": 22847
},
"visx-grid": {
"esm": 18982,
"lib": 22665
},
"visx-group": {
"esm": 1648,
"lib": 2267
},
"visx-heatmap": {
"esm": 7394,
"lib": 8731
},
"visx-hierarchy": {
"esm": 12093,
"lib": 17910
},
"visx-legend": {
"esm": 26944,
"lib": 34024
},
"visx-marker": {
"esm": 9152,
"lib": 11350
},
"visx-mock-data": {
"esm": 326040,
"lib": 329480
},
"visx-network": {
"esm": 4674,
"lib": 6809
},
"visx-pattern": {
"esm": 11689,
"lib": 15763
},
"visx-point": {
"esm": 1003,
"lib": 1818
},
"visx-react-spring": {
"esm": 14000,
"lib": 17725
},
"visx-responsive": {
"esm": 20892,
"lib": 26221
},
"visx-scale": {
"esm": 18649,
"lib": 30334
},
"visx-shape": {
"esm": 86912,
"lib": 108820
},
"visx-stats": {
"esm": 13738,
"lib": 15320
},
"visx-text": {
"esm": 8567,
"lib": 10114
},
"visx-threshold": {
"esm": 2907,
"lib": 3806
},
"visx-tooltip": {
"esm": 14976,
"lib": 21474
},
"visx-visx": {
"esm": 1524,
"lib": 4487
},
"visx-voronoi": {
"esm": 2314,
"lib": 3021
},
"visx-wordcloud": {
"esm": 2620,
"lib": 3455
},
"visx-xychart": {
"esm": 177399,
"lib": 239197
},
"visx-zoom": {
"esm": 16077,
"lib": 19135
}
} Current{
"visx-annotation": {
"esm": 31002,
"lib": 43431
},
"visx-axis": {
"esm": 21861,
"lib": 26466
},
"visx-bounds": {
"esm": 2948,
"lib": 3371
},
"visx-brush": {
"esm": 54136,
"lib": 58297
},
"visx-chord": {
"esm": 3478,
"lib": 4691
},
"visx-clip-path": {
"esm": 4524,
"lib": 6062
},
"visx-curve": {
"esm": 323,
"lib": 1462
},
"visx-demo": {
"esm": 0,
"lib": 36504
},
"visx-drag": {
"esm": 12756,
"lib": 14402
},
"visx-event": {
"esm": 3878,
"lib": 5194
},
"visx-geo": {
"esm": 13515,
"lib": 16741
},
"visx-glyph": {
"esm": 15177,
"lib": 19992
},
"visx-gradient": {
"esm": 18202,
"lib": 22847
},
"visx-grid": {
"esm": 18982,
"lib": 22665
},
"visx-group": {
"esm": 1648,
"lib": 2267
},
"visx-heatmap": {
"esm": 7394,
"lib": 8731
},
"visx-hierarchy": {
"esm": 12093,
"lib": 17910
},
"visx-legend": {
"esm": 26944,
"lib": 34024
},
"visx-marker": {
"esm": 9152,
"lib": 11350
},
"visx-mock-data": {
"esm": 326040,
"lib": 329480
},
"visx-network": {
"esm": 4674,
"lib": 6809
},
"visx-pattern": {
"esm": 11689,
"lib": 15763
},
"visx-point": {
"esm": 1003,
"lib": 1818
},
"visx-react-spring": {
"esm": 14000,
"lib": 17725
},
"visx-responsive": {
"esm": 12972,
"lib": 16175
},
"visx-scale": {
"esm": 18649,
"lib": 30334
},
"visx-shape": {
"esm": 86912,
"lib": 108820
},
"visx-stats": {
"esm": 13738,
"lib": 15320
},
"visx-text": {
"esm": 8567,
"lib": 10114
},
"visx-threshold": {
"esm": 2907,
"lib": 3806
},
"visx-tooltip": {
"esm": 14976,
"lib": 21474
},
"visx-visx": {
"esm": 1524,
"lib": 4487
},
"visx-voronoi": {
"esm": 2314,
"lib": 3021
},
"visx-wordcloud": {
"esm": 2620,
"lib": 3455
},
"visx-xychart": {
"esm": 178125,
"lib": 239923
},
"visx-zoom": {
"esm": 16077,
"lib": 19135
}
} |
packages/visx-responsive/Readme.md
Outdated
import { ResizeObserver } from 'your-favorite-polyfill'; | ||
|
||
function App() { | ||
return <Label resizeObserverPolyfill={ResizeObserver} {...} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this can be globally configured instead so users don't have to pass it around any time they need to use the observer? E.g.
import { ResizeObserver } from 'your-favorite-polyfill';
import { setResizeObserverPolyfill } from '@visx/responsive';
setResizeObserverPolyfill(ResizeObserver)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's a great idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may pursue that as a followup since it could be added as a util to complement the props
-based approach. I think we'd prob still want both options.
356b1d0
to
fcbc680
Compare
💥 Breaking Changes
Cleaning up some legacy stuff here in preparation for the
3.0.0
breaking release:@visx/responsive
ParentSizeModern
andwithParentSizeModern
which assume a globally-availableResizeObserver
polyfillResizeObserver
polyfill inParentSize
andwithParentSize
, and addsresizeObserverPolyfill
as an optionalprop
(component) / option (enhancer). this mirrors how@visx/tooltip
and@visx/annotation
handle this polyfill requirment@visx/xychart
@visx/responsive
, so bringing in the above change requires that we now polyfillResizeObserver
. instructions were added to the readme, but this can be done either globally, or through prop injection onXYChart
<Tooltip />
and<AnnotationLabel />
inside@visx/xychart
already required such a polyfill, so this shouldn't be a huge problem for upgrading (tho it is definitely a breaking change)