Skip to content

Kndgy/jsx-transform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

convert jsx/tsx to json and json to jsx/tsx

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published