0.9.0 • Published 2 years ago

@uni-component/react v0.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@uni-component/react npm build status coverage

Unified component for React.

Installation

pnpm add @uni-component/core @uni-component/react
# or with yarn
yarn add @uni-component/core @uni-component/react
# or with npm
npm install @uni-component/core @uni-component/react

Usage

UniComponent to React component:

import { uni2React } from '@uni-component/react'

export const ReactButton = uni2React(UniButton, (props, state, { renders }) => {
  const {
    n,
    rootClass,
    clickAction
  } = state
  const t = props.text ? props.text : renders.defaultRender && renders.defaultRender()
  return (
    <button className={rootClass} type={props.type} onClick={() => clickAction()}>
      <span>
        <>
          {t}
          {` ${n}`}
        </>
      </span>
      {props.appendRender?.()}
    </button>
  )
})

Entry:

/// <reference types="@uni-component/react/platform" />
import { h, Fragment } from '@uni-component/core'
import '@uni-component/react'
import ReactDOM from 'react-dom'

const App = () => {
  return (
    <>
      <ReactButton>child</ReactButton>
      <ReactButton primary={true} text='text'></ReactButton>
    </>
  )
}

ReactDOM.render(<App />, document.getElementById('root'))

JSX with tsconfig: { "jsxFactory": "h", "jsxFragmentFactory": "Fragment" }

0.9.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.6.3

2 years ago

0.8.0

2 years ago

0.6.2

2 years ago

0.6.4

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.4.3

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.4.2

2 years ago

0.0.1

2 years ago