@hrgui/react-dynamic-json
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

@hrgui/react-dynamic-json

Allows JSON as an input for a React component. Useful for making react components primarily with JSON objects, just like how React works.

Note that this is really just a wrapper around React.createElement.

WARNING / DISCLAIMER

Sanitize and CHECK where your props come from before using DynamicJson in production, OR ELSE YOU MAY GET FIRED

If you must need to use dangerouslySetInnerHTML, pass in allowDangerouslySetInnerHTML to <DynamicJson />.

Usage

yarn install @hrgui/react-dynamic-json

Hello World

import { DynamicJson } from '@hrgui/react-dynamic-json';

export function App() {
  return <DynamicJson component="div" props={{ children: ['Hello World'] }} />;
}

Nested children

import { DynamicJson } from '@hrgui/react-dynamic-json';

export function App() {
  return (
    <DynamicJson
      component="div"
      props={{
        children: [
          'Hello World',
          {
            component: 'h1',
            props: {
              children: ['Hello World 2'],
            },
          },
        ],
      }}
    />
  );
}

Readme

Keywords

none

Package Sidebar

Install

npm i @hrgui/react-dynamic-json

Weekly Downloads

1

Version

0.2.2

License

MIT

Unpacked Size

23.5 kB

Total Files

12

Last publish

Collaborators

  • hrgui