Releases: preactjs/preact-render-to-string
3.0.2
TL;DR: 3.0.0's
{jsx:true}option has been replaced withpreact-render-to-string/jsx.
3.0.0 added support for test-style JSX rendering (complex attributes rendered out using pretty-format). However, pretty-format actually doubled the size of preact-render-to-string and broke support for Node 4 and prior.
Instead of adding weight to the core library, which is often used in browsers (this library is part of preact-compat, for example), it's better to support these two "modes" via separate entrypoints into the module.
Here's the new solution - the library is now split into two different entrypoints, one for HTML/XML rendering, and the other specialized entry for JSX-style debug rendering.
Normal Mode
import renderToString from 'preact-render-to-string';JSX-Style Mode (for test frameworks, debugging, etc)
import renderToString from 'preact-render-to-string/jsx';3.0.0
- Add a
{ jsx:true }mode, which uses pretty-format to render complex JSX-style attribute values. This is useful for debugging purposes, and for preact-jsx-chai
2.8.0
Fixes
Preact 5.2+ started passing Object style props through to the DOM better rendering performance, but that broke
renderToString(). This fixes it!
Features
- #6 - Invoke
componentWillMount()for stateful components just beforerender(). Thanks @mikestead!
2.7.0
2.6.1
2.6.0
2.5.0
2.4.0
-
Generate globally unique common names for unnamed components, instead of falling back to "Component".
Unnamed components are now rendered as
<UnnamedComponent0>, where0is an internal ID. Two identical components (referentially equal) will render with the same name, useful for testing unnamed components. -
Don't assume
Function.prototypeexists (it doesn't for ES2015 arrow functions) -
Add a
renderRootComponent:falseoption, which skips rendering for components located at the root of the given JSX tree.Example:
render(<Foo>a</Foo>) === '<Foo>a</Foo>'
2.3.0
- Add
sortAttributesoption. When set totrue, attributes are sorted by name lexicographically during serialization. Useful for testing, such as via preact-jsx-chai