🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@dunggramer/jsx-runtime

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@dunggramer/jsx-runtime

A preset for using JSX without React.js

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

JSX Lite

| Using JSX without React.js

https://nodei.co/npm/jsx-lite.png?downloads=true&downloadRank=true&stars=true

Installation

npm install -D @jsx-lite/jsx-runtime
# or
yarn add -D @jsx-lite/jsx-runtime
# or
pnpm add -D @jsx-lite/jsx-runtime

Open babel.config.js or .babelrc and add the following line:

.babelrc:

...
"presets": [
    [
        "@babel/preset-react", {
            "runtime": "automatic",
            "importSource": "@jsx-lite"
        }
    ]
]
...

babel.config.js:

...
presets: [
     [
        '@babel/preset-react',
        {
          runtime: 'automatic',
          importSource: '@jsx-lite',
        },
    ],
]

Usage

Render to DOM

import { render } from "@jsx-lite/jsx-runtime";

const App = <h1>Hello, world!</h1>;
render(<App />, document.getElementById("root"));

Query Selector

    const Button = () => (
        <button
            ref={(el) => {
                if (el) {
                    el.addEventListener('click', () => {
                        alert('Hello, world!');
                    });
                }
            }}
        >Print</button>;
    )

Fragment

    const Badge = ({content}) => (
        <>
            <span>{content}</span>
        </>
    );

Children

    const Wrapper = ({children}) => (
        <div>
            {children}
        </div>
    );

    const App = () => (
        <Wrapper>
            <Badge content="Hello, world!" />
        </Wrapper>
    );

Set attribute

    const Icon = ({name, color}) => (
        <i class={`icon icon-${name}`} style={ 'color:' + color } />
    );

Keywords

babel

FAQs

Package last updated on 16 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts