1.1.2 • Published 6 years ago

preact-to-json v1.1.2

Weekly downloads
184
License
MIT
Repository
github
Last release
6 years ago

preact-to-json

Build Status npm devDependencies

Convert Preact components to JSON.

Note: This library currently only supports shallow rendering. If you need full (non-shallow) rendering, check out nathancahill/preact-render-to-json.

Installation

$ yarn add --dev preact-to-json

Usage

// ES6
import render from 'preact-to-json'

// ES5
const { render } = require('preact-to-json')

// With Jest
describe('Component', () => {
  it('renders', () => {
    const Component = () => (<a href="//google.com">Google</a>)
    const element = render(<Component />)

    expect(element).toMatchSnapshot()
  })
})

// test.snap
exports[`Component renders 1`] = `
<a
  href="//google.com"
>
  Google
</a>
`;

Change Log

Full Change Log

v1.1.2 (2018-01-26)

  • [7201875d00] - Handle when null/undefined children are rendered (Neil Kistner)

License

MIT © Neil Kistner

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago