1.0.9 • Published 6 years ago

@loopmode/react-pretty-json v1.0.9

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

react-pretty-json

A react component that pretty-prints JSON data, based on http://jsfiddle.net/unlsj.

Usage

import React, { Component } from 'react';
import PrettyJson from '@loopmode/react-pretty-json';

export class App extends Component {
    state = {
        foo: "foo", 
        bar: "bar",
        nested: {
            stuff: "we needed a nested value",
            some: Immutable.fromJS({
                data: 'immutable as well!' 
            })
        }
    }
    render() {
        return (
            <PrettyJson json={this.state} onError={console.error} />
        );
    }
}

Props

json

json: PropTypes.oneOfType([PropTypes.object, PropTypes.string])

Either an object that will be converted to a JSON string, or a JSON string. If it's an object, it will be stringified to JSON first. It is allowed to pass immutable.js objects, or mixed objects containing immutables.

onPrettyPrint

onPrettyPrint: PropTypes.func

A function that will be invoked with the prettified html string in case of success.

onError

onError: PropTypes.func

A function that will be invoked with the error object in case of error.

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago