1.3.1 • Published 5 years ago

proppy-frint-react v1.3.1

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

proppy-frint-react

npm

FrintJS + React integration for ProppyJS


Guide

Installation

With npm:

$ npm install --save proppy react proppy-react frint-react proppy-frint-react

Via unpkg CDN:

<script src="https://unpkg.com/proppy@latest/dist/proppy.min.js"></script>
<script src="https://unpkg.com/proppy-frint-react@latest/dist/proppy-frint-react.min.js"></script>

<script>
  // available as `window.ProppyFrintReact`
</script>

Usage

In your Root component, wrap it with ProppyProvider component, and it will take care of getting all the providers from your FrintJS app automatically:

// components/Root.js
import React from 'react';
import { ProppyProvider } from 'proppy-frint-react';

import MyComponent from './MyComponent';

export default function Root() {
  return (
    <ProppyProvider>
      <MyComponent />
    </ProppyProvider>
  );
}

Now anywhere from your components tree, you can use the attach higher-order component:

// components/MyComponent.js
import React from 'react';
import { compose, withProps } from 'proppy';
import { attach } from 'proppy-react';

const P = compose(
  withProps((props, providers) => {
    const { app, foo } = providers;

    return { foo: foo };
  }),
  withProps({ bar: 'bar value' }),
);

function MyComponent(props) {
  const { foo, bar } = props;

  return <p></p>;
}

export default attach(P)(MyComponent);

API

ProppyProvider

For setting providers at React's context-level.

1.3.1

5 years ago

1.3.0

5 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago