1.0.3 • Published 1 year ago

jsx-transform-json v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

jsx-transform-json

Convert React components to JSON and the other way around, compatible with react typescript

CreateJsx(
    <div className='div-class'>
        <span style={{color:'black'}} className='span-class'>
            this is text
        </span>
    </div>
)
CreateJSON({
    type: "div",
    props: {
        className: "div-class",
        style: {},
        children: [
            {
                type: "span",
                key: null,
                ref: null,
                props: {
                    className: "span-class",
                    style: {
                        color: "black"
                    },
                    children: [
                        "this is text"
                    ]
                }
            }
        ]
    },
    key: null,
    ref: null
})

Supported properties

interface NodeJson {
    type: string | Function;
    key?: string | number | null;
    ref?: any;
    props: {
      className: string;
      style?: any;
      children: Array<NodeJson | string>;
    };
  }

Install

npm i jsx-transform-json
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago