1.0.1 • Published 6 years ago

@source4society/react-scepter-alert-decorator v1.0.1

Weekly downloads
1
License
AGPL-3.0
Repository
github
Last release
6 years ago

react-scepter-alert-decorator

Decorate a container so it can hook into the react-authapp-container messaging system

scepter-logo

redux-logo

react-boilerplate

airbnb-codestyle

Build Status

codecov

Installation

npm install @source4society/react-scepter-alert-decorator

or

yarn add @source4society/react-scepter-alert-decorator

Usage

This decorator hooks a container into the react-scepter-authapp-container message state, and adds a prop function called renderMessage that will display the message using the react-alert-component. You will need to pass in a function to handle the message label translations in order to get the decorator. It looks something like this:

const Component = (props) => <div>{props.renderMessage(props.message)}</div>; // A dummy component to wrap. This component just displays the message, but it could be anything.
import alertDecorator from '@source4society/react-scepter-alert-decorator';
const labels = (message) => message; // create your labels function. This example does not perform any translation of the messages
const withAlert = alertDecorator(labels);
export default compose(withAlert)(Component);