It's time for another Preact X release 🎉 The past weeks were very productive and we're very happy to have been able to improve Preact on many fronts.
mjs
is no more 💯 ✅
We are very happy to have removed our .mjs
bundles and are back with standard .js
files. This was a common error when trying out the alpha with webpack
because the resolution for mjs
files is different. We're very thankful for @lukeed who stepped up and created a workaround with a custom webpack plugin that we have been referring to. But we all knew that we wanted to correct that with our next release and make Preact work out of the box with webpack again. This release does just that and you can safely remove webpack-modules
👍
Developer Experience Enhancements 🛠️
For this release we spent a few days working on improving the developer experience when writing Preact apps. For that we added more warnings to preact/debug
which should catch some common issues you may have run into. These will be visible in your browsers console 🎉
- Warn on double encoding of JSX literals and other invalid nodes passed to
createElement/h
- Warn when an event handler is not a
function
- Warn when the container node passed to
render()
doesn't exist in the DOM - Warn on invalid dependencies passed to
useEffect/useLayoutEffect
Here is an example:
Other notable changes
Thanks to the stunningly beautiful "people demo" that @phaux contributed we were able to catch two issues when using Preact together with mobx-react
. Our compat shim is now on a level where mobx-preact
isn't needed anymore (it was lagging behind in terms of features compared to mobx-react
).
What's next
We brought in the first batches of reconciler fixes but have a few pending changes left to do. These mainly include fixes that will make Fragment
support rock solid and an enhancements to createContext
. When these are stable we'll move forward to a beta release 👍 We even have some cool performance improvements in the pipeline 🤫
You all are amazing!
As always we'd like to take time to thank everyone who has filed issues or participated in discussion. The issues in particular are much higher quality than just a few months ago. We've received quite a few comments on twitter or in person from friends working on other OSS projects that they love our community and the positivity ours is known for. Just wanted to pass on the praise to you all 🎉 ❤️
Without further ado, here is the full change set:
Features
- Add warnings for invalid
useEffect/useLayoutEffect
dependencies (#1495, thanks @JoviDeCroock) - Add warnings for
useMemo/useCallback
when dependencies haven't been specified (#1499, thanks @JoviDeCroock) - Add more
createElement
warnings in debug (#1494, thanks @marvinhagemeister) - Add warnings for
render()
(#1487, thanks @JoviDeCroock) - Add warning for invalid event handlers (#1409, thanks @JoviDeCroock)
- Add teardown to test-utils (#1458, thanks @JoviDeCroock)
- Add people demo from #1388 (#1453, thanks @andrewiggins @phaux)
- Add back
unstable_batchedUpdates
and replacemobx-preact
withmobx-react
in demo app (#1477, thanks @marvinhagemeister) - Add support for CSS Grid (#1407, thanks @JoviDeCroock)
- Switch from
*.mjs
->*.module.js
(#1425, thanks @marvinhagemeister) - Save 3 bytes (#1466, thanks @38elements)
- Add
teardown
totest-utils
(#1458, thanks @JoviDeCroock)
Bug Fixes
event.persist
should be a function, not an object (#1498, thanks @JoviDeCroock)- Fix Portal crashing devtools (#1491, thanks @marvinhagemeister)
- Fix stale DOM caused by empty Fragments (#1489, thanks @marvinhagemeister)
- Add test for fragment ordering (#1478, thanks @JoviDeCroock)
- Fix DOM removed before
componentWillUnmount
(#1471, thanks @marvinhagemeister) - Don't call
setState
callback or enqueue a render in constructor (#1454, thanks @JoviDeCroock) - Jump to the next childDom if its
_dom
isnull
(#1452, thanks @Almo7aya) - Apply compat normalisation for every
vnode
(#1450, thanks @JoviDeCroock) - Fix changes in getDerivedStateFromProps is not reflected to
_nextState
(#1446, thanks @mochiya98) - Fix missing mangle config for
_prevState
(#1442, thanks @mochiya98) - Always diff checked/value properties against the DOM. Fixes #1324. (#1438, thanks @utkarshkukreti) 🎉
- Add missing
test-utils
export inpreact/compat
(#1436, thanks @JoviDeCroock) - Replace
Object.assign
with custom assign function (#1433, thanks @marvinhagemeister) - Don't iterate over old CSS string (#1429, thanks @marvinhagemeister)
- Fix safari failing on calc with CSS Custom Properties in SauceLabs (#1428, thanks @marvinhagemeister)
- Don't append
px
suffix for CSS Custom Properties (#1426, thanks @marvinhagemeister) - Updated links to the funcy.js source. (#1420, thanks @michael-klein)
- Fix
componentDidUpdate
arguments (#1455, thanks @38elements) - Fix
tagName
prop trying to change element type (#1419, thanks @JoviDeCroock) - Fix missing className normalization on hydrate (#1421, thanks @marvinhagemeister)
- Fix inconsistencies in
act
(#1437, thanks @JoviDeCroock) - Always diff checked/value properties against the DOM. (#1438, thanks @utkarshkukreti)
- Render bailout on equal state transition (#1449, thanks @JoviDeCroock)
- support svg attributes (#1451, thanks @JoviDeCroock)
- Move context update logic to diffing (#1468, thanks @JoviDeCroock)
- Fix remove button adding todos in demo app (#1488, thanks @marvinhagemeister)
Typings
- Update option types (#1493, thanks @JoviDeCroock)
- Update internal compat types (#1483, #1456, thanks @38elements)
- Update internal context types (#1432, thanks @38elements)
- Update Component in internal.d.ts (#1443, thanks @38elements)
- Fix
vnode
type definition (#1447, thanks @38elements) - Remove unnecessary settings in tsconfig.json (#1457, thanks @38elements)