Preact 8
https://github.com/preactjs/preact
This release is a maintenance release and all users of the 8.x release line are encouraged to upgrade to it.
- Fix devtools bridge not working with react devtools v4 (#1876)
This is a maintenance release and fixes a minor issue with the packaging of the devtools
import. All users on the 8.x
release line are encouraged to upgrade.
- Fix a bug in
8.4
where nestedpreact.render()
calls would cause an infinite loop when flushing the mount queue. (#1269, thanks @pl12133!)
The cat is out of the bag 🙌 We finally revealed on what we have in store
for the next major version of preact which will be called Preact X 🎉 To give
you a sneak peak of what will be included check out this talk over at this.javascript
video, slides.
It's hard to make an estimate right now on when it will be released, but rest
assured we are nearly done and are working on upgrading the ecosystem
(cli, router,...) to ensure a smooth release.
That said we very excited about recent community contributions. This release
contains some awesome performance enhancements brought to you by @lowaa and
@rpetrich. On top of that there are some minor bug fixes and a lots of
improvements to our typings.
Thank you so much for everyone involved 👍
- Perf: Improve adding and removing large trees 🎉 (#1211, thanks @lowaa)
- Drain render queue in a single micro task 🎉 (#1135, thanks @rpetrich)
- Fix missing build when installing from git (#1251, thanks @garybernhardt)
- Fix invalid
ref
invocation (#1235, thanks @developit) - Fix
cloneElement
test (#982, thanks @decadef20) - Reorganize and improve render unit tests (#1199, thanks @andrewiggins)
- Improve
componentDidUpdate
tests (#1198, thanks @andrewiggins)
TypeScript Improvements!
- Add
onInvalid
form event (#1221, thanks @namankheterpal) - Fix
h()
overloads (#1246, #1214, thanks @gpoit, @garybernhardt) - Fix
AnyCompoent
type (#1249, thanks @scurker) - Use proper type for
key
(#1248, thanks @wojtczal) - Add
boolean
as a component child (#1219, thanks @KasparEtter) - Add
onError
image event (#1209, thanks @jackmoore) - Add support for
defaultProps
(#1181, thanks @Alexendoo) - Fix
cloneElement
definition (#1197, thanks @hiddedejong)
Flow improvements!
- Fix typings for
[email protected]
(#1230, thanks @ngyikp) - Refine
options
flow type (#1204, thanks @reyronald)
README Improvements!
- Add Ultimate-Guitar (#1244, thanks @JiLiZART)
- Add logo to README (#1243, thanks @reviewher)
- Add section for
[email protected]
(#1212, thanks @38elements) - Remove duplicate project (#1192, thanks @stephenmathieson)
- Fixes an issue in
8.3.0
whereprevState
(as passed to componentDidUpdate) pointed to the wrong interim state value when batching (#1186, thanks @carlhopf!) - TypeScript: Added ShadowRoot and DocumentFragment as parent option to render (thanks @cromefire!)
New Features!
🙌 We've added support for the new getDerivedStateFromProps()
and getSnapshotBeforeUpdate()
lifecycle hooks. (#1094 & #1112). A huge thank-you to @andrewiggins and @marvinhagemeister for their amazing work on this!
Improvements
- We're shipping
.mjs
now! (#1165, thanks @mathiasbynens for the nudge) - Fix an issue where
setState()
could mutate state in-place (#1170, thanks @Mitranim for the fix and @dandv for digging into the Apollo issue!) spellcheck={false}
is now set as an attribute (#1110, thanks @marvinhagemeister!)- Some code golfing to offset the new lifecycle methods (#1122, thanks @andrewiggins, @marvinhagemeister)
- A little perf/size tweak for render callbacks (#1113, thanks @valotas)
- Someone found dead code in Preact! awesome. (#890, thanks @MrErHu & @clarkdo)
- We've dropped IE9 and IE10 from our SauceLabs tests (thanks @mkxml!)
Note: Preact will continue to support these browsers (that is to say, continue to avoid relying on features they don't support), but recent updates to Mocha mean our tests don't run there. Special thanks to @mkxml, @andrewiggins, @k1r0s and @marvinhagemeister for working to improve the test suite in this release!
TypeScript Improvements!
- Add support for specifying the types of a component's children (#1116, thanks @Alexendoo)
- Add
on*Capture
event handler attributes and PointerEvents to the TS definitions (#1101 #1102, thanks @jakearchibald) - Improve render()'s return type (#1085, thanks @valotas)
- Add
controlsList
attribute for media elements (#1134, thanks @wayou)
This release fixes an issue with our minification pipeline, which incorrectly mangled export declarations.
- Don't mangle module exports #1077, thanks @marvinhagemeister
- [ts] Add missing
ref
andkey
attribute #1051, thanks @andrewiggins - [ts] Add default parameter for Generic argument of
VNode
#1082, thanks @andrewiggins - [ts] Remove devtools module declaraction #1083, thanks @andrewiggins
We're happy to cut a new release and are excited about the much improved TypeScript defintions.
We love how much the community around preact has grown in the past months (18k stars!) and we'd like to thank everyone who was involved. Wether you've helped finding bugs, made code contributions or improved our documentation, this release wouldn't be possible without you. :tada:
Changes:
- [ts] Rewrite TypeScript defninitions and add support for strict mode
- #1071, thanks @levrik
- #1044 #1033 #1026, thanks @marvinhagemeister
- #1037, thanks @k1r0s
- #1027, thanks @wuweiweiwu
- #869, thanks @niedzielski
- #737, thanks @valotas
- #695, thanks @jmrog
- #1015, thanks @ovr
- #1005, thanks @jrf0110
- #1003, thanks @programbo
- #990, thanks @timurista
- #933, thanks @scurker
- #943, thanks @andybons
- Fix HMR sometimes throwing with
preact-router
#988, thanks @developit
- Fix
preact/debug
failing to load in Webpack 3 + ES Modules (#924 #935, thanks @whitetrefoil) - Added null to paren union type of render (#937, thanks @nickytonline)
- [debug]: Warn when passing incorrect arguments to
render()
(#885, thanks @markselby9) - [ts]: stateful component should be assignable to
AnyComponent
(#905, thanks @mike-north) - [ts]: add link preload "as" to
HTMLAttributes
type definition (#907, thanks @niedzielski) - [flow]: Fix flow types and render method issue (#868, thanks @sgrowe)
This release makes some tweaks to the newly released preact/debug
.
- Enhanced errors for
preact/debug
- Fixed issue where key warnings could be shown for components without keys
8.2.2 fixes a bunch of little issues encountered by those upgrading to 8.2.1 👍
- Use explicit import paths in
src
for ES Modules compatibility (#792, thanks @slaskis) - Fix CLI donation message failing if
npm
is unavailable (#804, thanks @andrejsm) - Fix Babel attempting to use Preact's configuration (#825, thanks @rubenmoya)
- Fix invalid sourcemap by updating Rollup (#800)
preact/debug
: Support for attributes with no.toString()
(#754, thanks @plusCubed)preact/debug
: Allow string refs when preact-compat is present (#807)preact/debug
: Fix error whenpreact-compat
was not present
- We're now shipping an ES Modules build and are using Babel 6! (thanks @btd, @matthewp, @gpoitch)
preact/debug
by @NekR: import it and get lovely warnings, errors & devtools integration!- Switch back to microtasks (via
Promise#then
) for async! (#708) - Fix unnecessary child reordering for certain cases (#717 - thanks @windyGex & @e1ectronic)
- Fix attributes not being removed when diffing against SSR'd DOM (#677, @dmail)
- Fixed Boolean and Number component render return values rendering
<undefined>
(#671, @dharFr) - Typescript Definition Improvements (#634, #641, #669, #730, #740)
- Optimizations (#672, #696, #697)
As of 8.1.0, we're officially out of beta! If you were waiting to upgrade to Preact 8, now's the time.
💁 8.x included a few important backwards-incompatible changes, so we've put together a 8.0 migration guide to help. The guide includes "polyfills" you can use to restore 7.x functionality so your migration goes smoothly.
If you have any issues upgrading, including anything caused by this release, drop us a line!
This release resolves a few issues people have had when upgrading.
- Remove object check before setting attributes (fixes custom toString, #401 - thanks @NekR!)
- Cast boolean children to null for component props (fixes rc-animate, #629 - thanks @hassanbazzi!)
- Call
componentDidMount
on children beforecomponentDidUpdate
on parent (#440, #506 - thanks @robertknight!) - Revert 8.0.0 behavior of throwing when encountering undefined components (#627)
preact/debug
will be released shortly and does a much better job reporting stack traces!
🌈 Also worth noting, the linkstate module is now available.
Quick follow-up to 8.0.0
- fixes an issue with
preact-router
(thanks @lukeed & @kbaxter!) - Fixes element removal regression in old IE (#625)
8.0.0 (beta)
It's here! 🌈
This release represents a huge step forward for Preact:
- Significantly increased performance - in some cases by 30%.
- Better compatibility -
key
for PFC's,class
integrations, capturing events. - Fewer edge cases - goodbye to unnecessary mounts and DOM hierarchy errors.
- Even smaller - Preact had been 3.9kb for a while - now it's 3.3kb (and headed for 2.9kb!)
💁 If you're looking to upgrade, be sure to read the quick guide.
Breaking Changes
- Pure Functional Components now have backing instances. This means
key
now works perfectly on PFC's. It also means you could use state and lifecycle methods in Functional Components... (#163, #517, #536, #586, #474) linkState()
has been removed from Preact itself. It is being published as a standalone linkstate module shortly.class
andclassName
no longer serialize Object values to Strings. Instead, use classnames (#401)preact/aliases
is no longer necessary.createElement()
is now an alias ofh()
right out of the box!- DOM element recycling has been removed. It was a source of issues for many, and is no longer necessary for great performance thanks to diff optimizations that reduce the number of cases where elements are removed and re-added. (#544, #351, #461, #459, #503, #535, #562)
- Undefined components references now throw rather than rendering
<undefined>
(#574) - No more
Symbol
. Instead of try to useSymbol.for('preactattr')
,__preactattr_
is always used. - Render debouncing now uses
setTimeout(0)
instead of Promises. It's smaller, doesn't swallow rendering errors in Safari, and was already the fallback (#357) - The non-standard
componentDidUnmount()
lifecycle method is removed. UsecomponentWillUnmount()
. onXxxxCapture
is now supported for registering capturing event handlers.- Events like
focus
andblur
are no longer automatically capturing by default.
Bugs Fixed
- Hierarchy errors are a thing of the past (thanks to recycler and PFC rewrites) (#380, #391)
- Fixed edge case that could cause children to be rendered out of order (#581, #603)
- Unmount lifecycle is always fired when replacing a Component with an empty element (#538, #534)
ref
functions attached to DOM nodes are no longer invoked for updates, only for mount/unmount.
Other Notable Changes
- "holes" in JSX children are now preserved and used intelligently by the diff (#580, #540)
- Re-rendering a compositional child with a different
key
prop now triggers a remount (#338) - JSX children passed to a Component are preserved rather than normalized (#551)
- Preact no longer relies on the
Text
orArray
constructors for type checks, instead relying on duck typing (#595, #530) - Ignore whitespace-only Text nodes during SSR hydration. SSR boot is now significantly faster than cold boot.
Here's the list of changes itemized by commit:
https://github.com/developit/preact/compare/master...8