jsx-sfc.macro

1.6.1 • Public • Published

jsx-sfc.macro

Babel macro for compile and enhance the limitation of jsx-sfc runtime code.

Usage

import React, { useState } from 'react';
import styled from 'styled-components';
import sfc from 'jsx-sfc.macro';

const App = sfc({
  Component() {
    const [user, setUser] = useState('foo');
    return { user, onClick: () => setUser('bar') };
  },

  render: ({ data, styles: { Wrapper } }) => (
    <Wrapper>
      <button onClick={data.onClick}>{data.user}</button>
    </Wrapper>
  ),

  styles: {
    Wrapper: styled.div`
      background-color: #fff;
    `
  }
});

How it works

The same as babel-plugin-jsx-sfc.

License

MIT

/jsx-sfc.macro/

    Package Sidebar

    Install

    npm i jsx-sfc.macro

    Weekly Downloads

    23

    Version

    1.6.1

    License

    MIT

    Unpacked Size

    7.16 kB

    Total Files

    5

    Last publish

    Collaborators

    • joe_sky