v8.0.14
See PR #313 for details.
ESP 8
This release updates esp-js-react from v16 to v18.
This PR introduces more modern react render patterns.
These largely negate the need to use ESPs connect() function and the corresponding mapModelToProps/createPublishEventProps on <ConnectableComponent />.
Context provider changes
ESP 8 adds or updates new hooks which work with 2 context providers:
<EspRouterContextProvider /> (renamed version of <RouterProvider />).
- This has always exposed
useRouter- not change to this API other than the rename of the provider.
<EspModelContextProvider />
This has:
useGetModelId()useGetModel()usePublishModelEvent()(existing)usePublishModelEventWithEntityKey()(existing)
How to use these?
<EspRouterContextProvider /> is designed to exist at the top of your app.
<EspModelContextProvider /> is designed to exist around V-DOM that is model specific,
if you're model is bound to the V-DOM using connect() or <ConnectableComponent /> it will automatically be wrapped in this provider making the hooks available.
Changes to the router subscription mechanism
connect() and <ConnectableComponent /> now back onto useSyncModelWithSelector to subscribe to the ESP Router for updates.
useSyncModelWithSelector internally use React.useSyncExternalStore to monitor for state changes via the ESP Router.
useSyncModelWithSelector doesn't technically need to find a <EspModelContextProvider /> at a higher level in the tree if the modelId is passed directly to it,
however, to make use of other hooks it's preferable to always have a <EspModelContextProvider /> at a higher point in the tree.
Breaking changes:
<SmartComponent />is gone - use<ConnectableComponent />(it's API compatible).
Renames:
<RouterProvided />- renamed to<EspRouterContextProvider />
Other notes
This update also has the following changes:
- Decommissioned Enzyme tests, tests are now using React Testing Library.
- Removed unused dependencies.
- Large test coverage increase for
esp-js-react. - Removed some unused code artifacts:
shallowEquals&shouldUpdateMixin