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
groups
prop onSelect
. Pass groups to theoptions
prop instead. (#1831) - Removed
Autocomplete.ComboBox.TextField
andAutocomplete.ComboBox.OptionList
. You should use theAutocomplete.TextField
andOptionList
components instead. (#1830) - Removed
secondaryFooterAction
prop onCard
. Pass an array of secondary actions to thesecondaryFooterActions
prop instead. (#1831) - Removed
iconBody
prop onNavigation.Item
. Pass a string to theicon
prop instead. (#1831) - Removed the
WithContext
component, as it was an undocumented part of the public API meant for internal use only (#1641) - Removed the
WithRef
component, 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-icons
instead. (#1604) - Removed support for passing an
SvgSource
shaped 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 intosource
will now always load an untrusted icon, you don't need that additional property. (#1604). - Removed
Navigation.UserMenu
. UseTopBar.UserMenu
instead. (#1599) - Made
title
a required prop onChoiceList
to improve accessibility. It can be hidden withtitleHidden
. (#1575) - Made
i18n
a required prop onAppProvider
. Usage instructions are included in theAppProvider
docs. (#1530) - Upgraded
react
andreact-dom
peer-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
esModuleInterop
intsconfig.json
. (#1523) - Removed
LinkLikeComponent
type export. UseAppProviderProps['linkComponent']
instead. (#1864) - Removed the
Modal.Dialog
andTabs.Panel
subcomponents as they were undocumented parts of our public API meant for internal use only (#1899).
Enhancements
- Added a new
create-react-app
example in TypeScript demonstrating use of Polaris withreact-testing
(#1937) - Exported
AppliedFilterInterface
andFilterInterface
fromFilters
(#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
onQueryFocus
callback prop to theFilters
component (#1948)
Bug fixes
- Fixed types merge of
ActionMenu
MenuAction
andMenuGroup.actions
(#1895) - Fixed the activator buttons of
Page
actionGroups
not toggling thePopover
active
state on click #1905 - Fixed Windows high contrast support of
Badge
progress
(#1928) - Fixed
BulkActionButton
from throwing an error incomponentDidMount
(#1913) - Fixed
ToastManager
from not working correctly inReact.StrictMode
(#1741) - Updated translation.yml with the new locales path (#1649)
- Fixed accessibility issue with
Tabs
list item presentation role (#1958) - Fixed cross-origin error being thrown in
Modal
when loading an external app (#1992) - Fixed regression in
PopoverOverlay
causingonClose
to be fired when Popover is opening and trigger was not the activator (#2000) - Fixed issue with
ContextualSaveBar
blocking search when hidden (#2044)
Documentation
- Updated
AppProvider
app bridge example to use ourAppBridgeContext
(#1877)
Development workflow
- Added support for React hooks in Storybook (#1665)
- Created
toBeDisabled
,mountWithContext
and added custom testing matchers (#1596) - Added
PolarisTestProvider
helper to ease configuration of required Polaris contexts in tests, see polaris examples for usage (#1810) - Enabled strict mode in TypeScript (#1883)
- Moved to
unpkg.com
for 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/polaris
in all examples to 4.0.0-rc.2 (#1937) - Added
@material-ui/react-transition-group
and removedreact-transition-group
to supportReact.StrictMode
(#1759) - Added
@shopify/react-testing
(#1596) - Removed
@shopify/css-utilities
(#1586) - Removed
@types/prop-types
andprop-types
(#1505) - Updated
react
to 16.8.6 andenzyme
to 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
withAppProvider
to use a functional component rather than a class component (#1813) - Updated
Link
to useuseI18n
rather thanwithAppProvider
(#1806) - Updated several components to use hooks instead of
withAppProvider
(#1797) - Removed
CSSTransition
fromPopoverOverlay
(#1756) - Updated exports in
src/utilities
andsrc/test-utilities
to named exports (#1717) - Removed test errors and non-deprecation warnings (#1715)
- Enabled
React.StrictMode
in test components and Storybook (#1709) - Removed all uses of
ReactDOM.findDOMNode
(#1696) - Enabled
react/no-unsafe
ESLint rule withcheckAliases
(#1695) - Alphabetized component export order and kebab-case files (#1674)
- Updated
Collapsible
to no longer usecomponentWillReceiveProps
(#1670) - Restructured context structure to be more modular (#1664)
- Updated
PositionedOverlay
to no longer usecomponentWillReceiveProps
(#1621) - Simplified
WithinContentContainer
context type (#1602) - Updated
OptionList
to no longer usecomponentWillReceiveProps
(#1557) - Refactored
RangeSlider
DualThumb
tests (#1548) - Converted
Sheet
to a functional component (#1548) - Removed
withContext
fromResourceList.Item
(#1503) - Removed
withContext
fromNavigation.Item
(#1502) - Removed
withRef
fromUnstyledLink
(#1501) - Removed
withContext
fromResourceList.FilterControl
(#1500) - Removed
withContext
fromScrollable.ScrollTo
and added a test to boost coverage (#1499) - Removed
withContext
fromLoading
(#1497) - Removed
withContext
andwithAppProvider
fromContextualSaveBar
(#1498) - Removed
withContext
fromToast
(#1494) - Removed
withRef
andwithContext
fromDropZone.FileUpload
(#1491) - Created
useAppBridge
hook (#1482) - Removed testID warning in tests (#1447)
- Updated
AppProvider
to 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
Autocomplete
component from legacy context API to use createContext (#1403) - Upgraded the
Navigation
component from legacy context API to use createContext (#1402) - Updated
ThemeProvider
to use the new context API (#1396) - Updated
AppProvider
to no longer usecomponentWillReceiveProps
(#1255) - Removed unused context from
Scrollable
(#1253) - Updated
ThemeProvider
to no longer usecomponentWillReceiveProps
(#1254) - Removed context from
Collapsible
(#1114) - Refactored
Frame
and its subcomponents to use thecreateContext
API instead of legacy context (#803) - Upgraded the
Banner
,Card
, andModal
components from legacy context API to usecreateContext
(#786)
Deprecations
- Renamed
singleColumn
onPage
tonarrowWidth
(#1606)