https://github.com/loopmode/react-pretty-json
A react component that pretty-prints JSON data, based on http://jsfiddle.net/unlsj/
https://github.com/loopmode/react-pretty-json
Last synced: about 1 year ago
JSON representation
A react component that pretty-prints JSON data, based on http://jsfiddle.net/unlsj/
- Host: GitHub
- URL: https://github.com/loopmode/react-pretty-json
- Owner: loopmode
- Created: 2018-03-31T07:50:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T08:25:03.000Z (over 7 years ago)
- Last Synced: 2025-02-09T03:05:36.272Z (about 1 year ago)
- Language: JavaScript
- Size: 41 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# react-pretty-json
A react component that pretty-prints JSON data, based on http://jsfiddle.net/unlsj.

## Usage
```javascript
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 (
);
}
}
```
### 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.