How to use the react-sweet-state.defaults.middlewares function in react-sweet-state

To help you get started, we’ve selected a few react-sweet-state examples, based on popular ways it is used in public projects.

github atlassian / react-sweet-state / examples / advanced-flow / index.js View on Github external
import '@babel/polyfill';

import { UserListRpc, UserListHook } from './views/user-list';
import { TodoListRpc, TodoListHook } from './views/todo-list';

/**
 * Add simple logger middleware
 */
const mw: Middleware = storeState => next => arg => {
  /* eslint-disable no-console */
  console.log(storeState.key, 'changing', arg);
  const result = next(arg);
  console.log(storeState.key, 'changed');
  return result;
};
defaults.middlewares.add(mw);
/**
 * Enable Redux devtools support
 */
defaults.devtools = true;

/**
 * Main App
 */
class App extends Component<{}> {
  render() {
    return (
      <div>
        <h1>User Todos example</h1>
        <main>
          <div>
            <h3>With Render-props</h3>

react-sweet-state

Global + local state combining the best of Redux and Context API

MIT
Latest version published 5 days ago

Package Health Score

87 / 100
Full package analysis