All Projects → alecsgone → Jsx Render

alecsgone / Jsx Render

Licence: mit
Lightweight util to render JSX without react

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Jsx Render

Jsx Lexer
a JSX lexer for pygments
Stars: ✭ 26 (-56.67%)
Mutual labels:  jsx
Jsx Lite
Write components once, run everywhere. Compiles to Vue, React, Solid, Angular, Svelte, and Liquid.
Stars: ✭ 1,015 (+1591.67%)
Mutual labels:  jsx
Universal React Demo
ES6 demo of a simple but scalable React app with react-router, code splitting, server side rendering, and tree shaking.
Stars: ✭ 50 (-16.67%)
Mutual labels:  jsx
Webmiddle
Node.js framework for modular web scraping and data extraction
Stars: ✭ 13 (-78.33%)
Mutual labels:  jsx
Cattous
CSS in JSX for lazy developers, built using styled-components and styled-system
Stars: ✭ 38 (-36.67%)
Mutual labels:  jsx
React Es6 Padawan To Jedi Book
Uma introdução simples e completa para React usando ES6 e Babel.
Stars: ✭ 46 (-23.33%)
Mutual labels:  jsx
Htm
Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.
Stars: ✭ 7,299 (+12065%)
Mutual labels:  jsx
Calendar Graph
Calendar graph like github using jsx support SVG, Canvas and SSR
Stars: ✭ 58 (-3.33%)
Mutual labels:  jsx
Rich Text To Jsx
📄 Opinionated JSX renderer for the Contentful rich text field type.
Stars: ✭ 39 (-35%)
Mutual labels:  jsx
React Native Hotels App
⛺️ Hotels App: A simple react-native App exercise with nodeJS API consumption
Stars: ✭ 50 (-16.67%)
Mutual labels:  jsx
Babel Plugin Jsx Two Way Binding
🍺 A two-way data binding solution for React
Stars: ✭ 15 (-75%)
Mutual labels:  jsx
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-43.33%)
Mutual labels:  jsx
Chatblocks
Declarative Messenger chatbot framework
Stars: ✭ 48 (-20%)
Mutual labels:  jsx
Muve
Muve is a micro library for building interactive javascript applications.
Stars: ✭ 11 (-81.67%)
Mutual labels:  jsx
Cascade
A modern library for creating user interfaces.
Stars: ✭ 50 (-16.67%)
Mutual labels:  jsx
Preppy
A simple and lightweight tool for preparing the publish of NPM packages.
Stars: ✭ 23 (-61.67%)
Mutual labels:  jsx
Inferno Most Fp Demo
A demo for the ReactJS Tampa Bay meetup showing how to build a React+Redux-like architecture from scratch using Inferno, Most.js, reactive programmning, and various functional programming tools & techniques
Stars: ✭ 45 (-25%)
Mutual labels:  jsx
Markdown To Jsx
🏭 The most lightweight, customizable React markdown component.
Stars: ✭ 1,079 (+1698.33%)
Mutual labels:  jsx
Js Toolbox
CLI tool to simplify the development of JavaScript apps/libraries with little to no configuration. (WORK IN PROGRESS/PACKAGE NOT PUBLISHED).
Stars: ✭ 53 (-11.67%)
Mutual labels:  jsx
Gatsby Plugin Mdx
gatsby v1 mdx plugin, for gatsby v2 see https://github.com/ChristopherBiscardi/gatsby-mdx
Stars: ✭ 50 (-16.67%)
Mutual labels:  jsx

JSX-render

travis

Small file to render jsx as a stateless component from react but without the heavy kb use of it.

Contents

Quick Start

(no build system, just plain html)

<!-- index.html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.21.1/babel.min.js"></script>
<script type="text/javascript" src="https://alecsgone.github.io/jsx-render/jsx.js"></script>
<script>
  Babel.registerPreset('jsx-render', {
    presets: [[Babel.availablePresets['es2015']]],
    plugins: [
      Babel.availablePlugins['syntax-jsx'],
      [
        Babel.availablePlugins['transform-react-jsx'],
        {
          pragma: 'jsx.dom',
          pragmaFrag: 'jsx.Fragment',
        },
      ],
    ],
  })
</script>

<script type="text/babel" data-presets="jsx-render">
  const foo = () => <p>Hello world</p>

  document.body.appendChild(foo())
</script>

How To Install

The required packages are @babel/plugin-syntax-jsx, @babel/plugin-transform-react-jsx and of course jsx-render, additionally you will need @babel/core, webpack or any other way to transpile the code that you prefer.

$ npm install jsx-render @babel/plugin-syntax-jsx @babel/plugin-transform-react-jsx

Getting started

Make sure you have the pragma fn defined and its name is "dom"

// .babelrc
{
  "presets": ["babel-preset-primavera", ["@babel/preset-react", { "pragma": "dom" }]]
}

Now you can create components e.g.

import dom from 'jsx-render'

const DummyComponent = props => <div>{props.children}</div>
export default DummyComponent

or Fragments

import dom, { Fragment } from 'jsx-render'
import DummyComponent from './DummyComponent'

const Modal = props => (
  <div>
    <header>Include {props.title}</header>
    <Fragment>
      <div>Body</div>
      <DummyComponent>Copyright</DummyComponent>
    </Fragment>
  </div>
)

Features

  • new Class suport with default target: the render() method
  • Render Basic Single Components <div />
  • Conditional Component {condition ? <foo/> : <bar/>}
  • Component with Data Attributes <div data-some="attr">
  • Component with Attributes <img src="foo.jpg">
  • Nested Component ul>li>a
  • Siblings Components ul>li*3
  • Components with classname p.chan
  • Map components & numbers array.map(item => <div>{item}</div>)
  • Fragments
  • Portals
  • SVG
  • Component Props <Custom foo="foo">
  • Component Children <Custom>children</Custom>
  • Component render xlinkHref for SVG sprites
  • dangerouslySetInnerHTML
  • Components withState Redux not included

Fragments

import dom, { Fragments } from 'jsx-render'

// Return siblings without direct parent component
const Foo = () => (
  <Fragments>
    <li />
    <li />
  </Fragments>
)
const ul = document.createElement('ul')
ul.appendChild(<Foo />)

Portals

import dom, { portalCreator } from 'jsx-render'

// can render the component on a diferent node than the parentNode
// useful for modals, and if the argument is not a node
// it will render as body direct son by default
function Component(node) {
  const Portal = portalCreator(node)

  return (
    <div>
      <Portal>
        <span>uno</span>
      </Portal>
    </div>
  )
}

dangerouslySetInnerHTML

function render() {
  return <div dangerouslySetInnerHTML={{ __html: '<span>StrangerDanger</span>' }} />
}

Recipes

Testing

Testing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].