Skip to content

Releases: preactjs/preact-render-to-string

3.0.6

20 Sep 23:44
Compare
Choose a tag to compare
  • Fix JSX rendering being non-deterministic about empty VNodes

3.0.5

03 Aug 22:58
Compare
Choose a tag to compare
  • JSX Mode: skip attributes with null and undefined values
  • JSX Mode: don't use self-closing tags as they make string assertions less useful

3.0.2

03 Aug 00:48
Compare
Choose a tag to compare

TL;DR: 3.0.0's {jsx:true} option has been replaced with preact-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

02 Aug 23:15
Compare
Choose a tag to compare
  • 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

29 Jul 20:47
Compare
Choose a tag to compare

Fixes

  • #7 - Serialize object style attributes to style strings. Thanks @rmales!

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 before render(). Thanks @mikestead!

2.7.0

22 Jul 16:33
Compare
Choose a tag to compare
  • Add support for defaultProps on both pure and class components (#5)

2.6.1

22 Jul 16:33
Compare
Choose a tag to compare
  • Skip children, key and ref attributes when rendering to HTML.

2.6.0

22 Jul 16:32
Compare
Choose a tag to compare
  • Fix falsey and boolean attributes so they render properly in HTML and XML modes

2.5.0

04 May 18:24
Compare
Choose a tag to compare
  • Add support for a {pretty:true} option, which outputs formatting whitespace. This release is dedicated to @drastick for his tenure.
prettyRender(
    <section>
        <a href="/foo">foo</a>
        bar
        <p>hello</p>
    </section>
);

// output:
<section>
    <a href="/foo">foo</a>
    bar
    <p>hello</p>
</section>

2.4.0

14 Apr 02:07
Compare
Choose a tag to compare
  • Generate globally unique common names for unnamed components, instead of falling back to "Component".

    Unnamed components are now rendered as <UnnamedComponent0>, where 0 is an internal ID. Two identical components (referentially equal) will render with the same name, useful for testing unnamed components.

  • Don't assume Function.prototype exists (it doesn't for ES2015 arrow functions)

  • Add a renderRootComponent:false option, which skips rendering for components located at the root of the given JSX tree.

    Example:

    render(<Foo>a</Foo>) === '<Foo>a</Foo>'