simplified-jsx-to-json
/
0.5.0
simplified-jsx-to-json 0.5.0
Install from the command line:
Learn more about npm packages
$ npm install @cleartax/simplified-jsx-to-json@0.5.0
Install via package.json:
"@cleartax/simplified-jsx-to-json": "0.5.0"
About this version
Converts simplified JSX code into a JSON representation, which can be used by
React.createElement
$ npm install simplified-jsx-to-json
const jsxToJson = require('simplified-jsx-to-json');
jsxToJson('<Test myProp={true}>My Child</Test>');
//=> '[ [ 'Test', { myProp: true }, "My Child" ] ]'
-
<Test />
: Self-closing JSX tags -
<Test myProp="string">
: String props -
<Test myProp={`string`}>
: Template props -
<Test myProp>
: True props -
<Test myProp={false}>
: Boolean props -
<Test myProp={34}>
: Number props -
<Test myProp={3 + 3 + 3}>
: Props with arithmetic, comparison or bitwise operators -
<Test myProp={['Test', true, 34]}>
: Arrays (with strings, numbers or booleans) -
<Test myProp={{ test: 34 }}>
: Objects with string keys and string, number or boolean value -
<>Test</>
: Fragments - HTML/SVG DOM attributes are converted to correct React equivalent (
class
->className
)
MIT © Dennis Morhardt
Details
- simplified-jsx-to-json
- ClearTax
- over 2 years ago
- MIT
- 8 dependencies
Assets
- simplified-jsx-to-json-0.5.0-npm.tgz
Download activity
- Total downloads 8,690
- Last 30 days 379
- Last week 188
- Today 0