Comment on page


This decorator register component method on component did mount as state listener in eventrix and unregister when component will unmount.
"eventrixComponent" decorator is required if You want use any of eventrix component decorators
If You want use hooks, hocs or component decorator You must use EventrixProvider in Your application. Go to "EventrixProvider" page in "Context" section for more details.
import React from 'react';
import { eventrixComponent, stateListener } from 'eventrix';
class ClientsListCounter extends React.Component {
constructor(...args) {
this.state = {
clientsNumber: this.eventrix.getState('clients.list').length;
createCounter(clientsList) {
this.setState({ clientsNumber: clientsList.length });
render() {
return (
<div>Clients number: {this.state.clientsNumber}</div>
export default ClientsListCounter;
createCounter method will be called with clients list when clients.list state will change.