preact v10.2.0 Release Notes
Release Date: 2020-01-07 // over 4 years ago-
๐ Happy belated New Years to everybody ๐ We hope you enjoyed the holidays and had some time off to recharge ๐ Our very first release in 2020 brings two new features and the usual round of bug fixes ๐ฏ
๐ New
useErrorBoundary
hook๐ There is a new hook called
useErrorBoundary
which allows you to catch errors that are thrown by any child components. It's essentially the hook version ofcomponentDidCatch
.// 1. parameter is null or the error that was caught// 2. paremeter can be called to reset the stateconst [err, reset] = useErrorBoundary();// Optional: You can pass a callback function that will// be executed when an error occurs:const [err] = useErrorBoundary(() =\> callMeMaybe());
Usage example:
// Example component that will throw an error on renderconst SomeComponent = () =\> { throw new Error("fail"); };const App = props =\> { const [err] = useErrorBoundary(); if (err) { return \<p\>Something went wrong...\</p\>; } else { return \<SomeComponent /\>; } };
0๏ธโฃ Lazy works with non-default export
0๏ธโฃ This PR was one of the smallest ones, but something that makes working with different kind of lazy loaded modules a lot easier. Previously
lazy
would always use thedefault
export of the imported module. With this change it's now possible to use it with anyexport
.// Look ma, no default exportconst LazyFoo = lazy(() =\> import("./Foo").MyComponent);
๐ฑ On top of that we have the usual round of bug fixes. We'd like to thank everyone who reported them and helped us make Preact even better. Thank you so much!! ๐
๐ Features
- โ Add
useErrorBoundary
hook (#2205, thanks @JoviDeCroock) - ๐ Allow
lazy()
usage with non-default imports (#2212, thanks @developit)
๐ Bug Fixes
- ๐ Fix incorrect
ref
value on siblingvnodes
(#2217, thanks @JoviDeCroock) - ๐ Fix stale closure in error boundary (#2225, thanks @JoviDeCroock)
- ๐ Fix
Text
nodes being re-rendered unnecessarily (#2215, thanks @developit) - Shorten and correct
renderToString
dependency error (#2207, thanks @developit) - ๐ Support combination of
getDerivedStateFromError
andcomponentDidCatch
(#2200, thanks @JoviDeCroock) - ๐ Fix compat hydration (#2206, thanks @JoviDeCroock)
Typings
- โ Add
onReset/onFormData
to Form Event types (#2209, thanks @thesmartwon)
๐ง Maintenance
- โก๏ธ More README updates (#2235, thanks @developit)
- Modernize our README (#2232, thanks @JoviDeCroock)
- ๐ Update package metadata (#2230, thanks @developit)
- โ Add more test cases for
Suspense
(#2229, thanks @sventschui) - ๐ Fix renderer tests by using
sinon
global (#2220, thanks @JoviDeCroock) - โก๏ธ Update JSDoc comments (#2187, thanks @soulhat)
- โ Add