@source4society/react-scepter-alert-decorator
v1.0.1
Published
Decorate a container so it can hook into the react-authapp-container messaging system
Downloads
2
Readme
react-scepter-alert-decorator
Decorate a container so it can hook into the react-authapp-container messaging system
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);