stringify-prop-value-as

customize how object is serialized in react-element-to-jsx-string


Keywords
custom, serialization, pretty-print-object, storybook
License
MIT
Install
npm install stringify-prop-value-as@0.1.0

Documentation

stringify-prop-value-as

customize how a prop value is stringified with react-element-to-jsx-string

created in order to make storybook source blocks easier to digest when working with complex prop values.

Install

npm i stringify-prop-value-as
# yarn add stringify-prop-value-as

Use

import { createElement } from 'react';
import reactElementToJSXString from 'react-element-to-jsx-string';
import stringifyPropValueAs from 'stringify-prop-value-as';

const options = stringifyPropValueAs(
  { test: 'hello', arr: [1, 2, 3] },
  'MY_OBJECT',
);

console.log(reactElementToJSXString(<h1 options={options} />));
/* <h1 options={MY_OBJECT} /> */