v4.0.0
Polaris React v4.0.0 is a major release that introduces breaking changes, primarily due to updates made to component internals. This builds a stronger foundation that ensures readiness for future React performance improvements.
This release doesn’t include any new components, but it does update some components to use React Hooks. It also deletes several deprecated features and removes dependencies on legacy context and unsafe lifecycle methods. Thanks to these improvements, Polaris React is React Strict Mode compliant.
For instructions on updating from v3 to v4, read the migration guide.
Breaking changes
- Removed
groupsprop onSelect. Pass groups to theoptionsprop instead. (#1831) - Removed
Autocomplete.ComboBox.TextFieldandAutocomplete.ComboBox.OptionList. You should use theAutocomplete.TextFieldandOptionListcomponents instead. (#1830) - Removed
secondaryFooterActionprop onCard. Pass an array of secondary actions to thesecondaryFooterActionsprop instead. (#1831) - Removed
iconBodyprop onNavigation.Item. Pass a string to theiconprop instead. (#1831) - Removed the
WithContextcomponent, as it was an undocumented part of the public API meant for internal use only (#1641) - Removed the
WithRefcomponent, as it was an undocumented part of the public API meant for internal use only (#1610) - Removed support for passing a string into
<Icon source>to load a bundled icon. You must load the required icon directly from@shopify/polaris-iconsinstead. (#1604) - Removed support for passing an
SvgSourceshaped object into<Icon source>to load an icon imported using Shopify’s legacy icon loader. You must update sewing-kit to at least v0.82.0 which replaced the legacy loader with using SVGR. (#1604) - Removed support for passing a React Element into
<Icon source>. You must pass in a React Component that returns an SVG element instead. (#1604) - Removed support for
<Icon untrusted>. Passing a string intosourcewill now always load an untrusted icon, you don't need that additional property. (#1604). - Removed
Navigation.UserMenu. UseTopBar.UserMenuinstead. (#1599) - Made
titlea required prop onChoiceListto improve accessibility. It can be hidden withtitleHidden. (#1575) - Made
i18na required prop onAppProvider. Usage instructions are included in theAppProviderdocs. (#1530) - Upgraded
reactandreact-dompeer-dependencies to 16.8.6 to enable the use of hooks (#1525) - Changed the import method for React to use default imports. Applications consuming Polaris using TypeScript must enable
esModuleInteropintsconfig.json. (#1523) - Removed
LinkLikeComponenttype export. UseAppProviderProps['linkComponent']instead. (#1864) - Removed the
Modal.DialogandTabs.Panelsubcomponents as they were undocumented parts of our public API meant for internal use only (#1899).
Enhancements
- Added a new
create-react-appexample in TypeScript demonstrating use of Polaris withreact-testing(#1937) - Exported
AppliedFilterInterfaceandFilterInterfacefromFilters(#1924) - Improved color contrast of links inside
Banner(#1651) - Add underline to Links and Plain button on hover, so it doesn't rely on color alone for accessibility (#1885)
- Add
onQueryFocuscallback prop to theFilterscomponent (#1948)
Bug fixes
- Fixed types merge of
ActionMenuMenuActionandMenuGroup.actions(#1895) - Fixed the activator buttons of
PageactionGroupsnot toggling thePopoveractivestate on click #1905 - Fixed Windows high contrast support of
Badgeprogress(#1928) - Fixed
BulkActionButtonfrom throwing an error incomponentDidMount(#1913) - Fixed
ToastManagerfrom not working correctly inReact.StrictMode(#1741) - Updated translation.yml with the new locales path (#1649)
- Fixed accessibility issue with
Tabslist item presentation role (#1958) - Fixed cross-origin error being thrown in
Modalwhen loading an external app (#1992) - Fixed regression in
PopoverOverlaycausingonCloseto be fired when Popover is opening and trigger was not the activator (#2000) - Fixed issue with
ContextualSaveBarblocking search when hidden (#2044)
Documentation
- Updated
AppProviderapp bridge example to use ourAppBridgeContext(#1877)
Development workflow
- Added support for React hooks in Storybook (#1665)
- Created
toBeDisabled,mountWithContextand added custom testing matchers (#1596) - Added
PolarisTestProviderhelper to ease configuration of required Polaris contexts in tests, see polaris examples for usage (#1810) - Enabled strict mode in TypeScript (#1883)
- Moved to
unpkg.comfor our CDN CSS assets, instead of usingsdks.shopifycdn.com. Existing URLs will continue to work but new versions will only be available atunpkg.com. (#1960) - Added ChromaUI integration for previewing Storybook builds, to potentially replace our self-hosted Heroku instance (#1975)
Dependency upgrades
- Updated
@shopify/polarisin all examples to 4.0.0-rc.2 (#1937) - Added
@material-ui/react-transition-groupand removedreact-transition-groupto supportReact.StrictMode(#1759) - Added
@shopify/react-testing(#1596) - Removed
@shopify/css-utilities(#1586) - Removed
@types/prop-typesandprop-types(#1505) - Updated
reactto 16.8.6 andenzymeto 3.9.1 (#1392)
Code quality
- Bumped test coverage in
Collapsible(#1929) - Bumped test coverage in
DropZone,Frame,Icon, andLoading(#1927) - Removed unused type definitions (#1862)
- Ignored deprecation warnings related to Shopify App Bridge in tests (#1852)
- Updated
withAppProviderto use a functional component rather than a class component (#1813) - Updated
Linkto useuseI18nrather thanwithAppProvider(#1806) - Updated several components to use hooks instead of
withAppProvider(#1797) - Removed
CSSTransitionfromPopoverOverlay(#1756) - Updated exports in
src/utilitiesandsrc/test-utilitiesto named exports (#1717) - Removed test errors and non-deprecation warnings (#1715)
- Enabled
React.StrictModein test components and Storybook (#1709) - Removed all uses of
ReactDOM.findDOMNode(#1696) - Enabled
react/no-unsafeESLint rule withcheckAliases(#1695) - Alphabetized component export order and kebab-case files (#1674)
- Updated
Collapsibleto no longer usecomponentWillReceiveProps(#1670) - Restructured context structure to be more modular (#1664)
- Updated
PositionedOverlayto no longer usecomponentWillReceiveProps(#1621) - Simplified
WithinContentContainercontext type (#1602) - Updated
OptionListto no longer usecomponentWillReceiveProps(#1557) - Refactored
RangeSliderDualThumbtests (#1548) - Converted
Sheetto a functional component (#1548) - Removed
withContextfromResourceList.Item(#1503) - Removed
withContextfromNavigation.Item(#1502) - Removed
withReffromUnstyledLink(#1501) - Removed
withContextfromResourceList.FilterControl(#1500) - Removed
withContextfromScrollable.ScrollToand added a test to boost coverage (#1499) - Removed
withContextfromLoading(#1497) - Removed
withContextandwithAppProviderfromContextualSaveBar(#1498) - Removed
withContextfromToast(#1494) - Removed
withRefandwithContextfromDropZone.FileUpload(#1491) - Created
useAppBridgehook (#1482) - Removed testID warning in tests (#1447)
- Updated
AppProviderto use the new context API and refactored other instances to follow a new pattern and refactor test utilities (#1424) - Updated all context files to export react context rather than a provider and consumer (#1424)
- Deleted
withSticky(#1424) - Upgraded the
Autocompletecomponent from legacy context API to use createContext (#1403) - Upgraded the
Navigationcomponent from legacy context API to use createContext (#1402) - Updated
ThemeProviderto use the new context API (#1396) - Updated
AppProviderto no longer usecomponentWillReceiveProps(#1255) - Removed unused context from
Scrollable(#1253) - Updated
ThemeProviderto no longer usecomponentWillReceiveProps(#1254) - Removed context from
Collapsible(#1114) - Refactored
Frameand its subcomponents to use thecreateContextAPI instead of legacy context (#803) - Upgraded the
Banner,Card, andModalcomponents from legacy context API to usecreateContext(#786)
Deprecations
- Renamed
singleColumnonPagetonarrowWidth(#1606)