frint-props-react

0.2.1 • Public • Published

frint-props

npm

Compose props reactively in FrintJS Apps


Guide

Installation

With npm:

$ npm install --save frint-props frint-react

Via unpkg CDN:

<script src="https://unpkg.com/frint-props@latest/dist/frint-props.min.js"></script>
<script>
  // available as `window.FrintProps`
</script> 

Usage

The package exposes a compose higher-order component, that is similar to the one found in frint-props.

You can use it as follows:

import React from 'react';
import { withDefaults, withState } from 'frint-props';
import { compose } from 'frint-props-react';
 
function MyComponent(props) {
  // props.counter (`Integer`)
  // props.setCounter (`Function`)
}
 
export default compose(
  withDefaults({ counter: 0 }),
  withState('counter', 'setCounter', 0)
)(MyComponent);

API

compose

compose(...functions)(Component)

Higher-order component in React.

Arguments

Accepts multiple functions as available in frint-props. The returned function is an enhancer that can be called directly with your base React component.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i frint-props-react

    Weekly Downloads

    84

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    15.4 kB

    Total Files

    13

    Last publish

    Collaborators

    • jbaudin
    • rmachado-travix
    • mmirandaalex
    • fahad19
    • markvincze
    • viacheslaff
    • oriente