How to use the react-redux.ReactReduxContext function in react-redux

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github americanexpress / iguazu / __tests__ / connectAsync.spec.jsx View on Github external
*/

import React, { createContext, cloneElement } from 'react';
import PropTypes from 'prop-types';
import { createStore, applyMiddleware } from 'redux';
import * as ReactRedux from 'react-redux';
import { mount as baseMount } from 'enzyme';
import thunk from 'redux-thunk';

import * as utils from '../src/utils';
import config from '../src/config';

// Module under test
import connectAsync from '../src/connectAsync';

ReactRedux.ReactReduxContext = createContext(null);

const { ReactReduxContext } = ReactRedux;

const FakeReduxContext = ({ context, children, ...restOfProps }) => (
  
    {cloneElement(children, restOfProps)}
  
);

FakeReduxContext.propTypes = {
  context: PropTypes.shape({}).isRequired,
  children: PropTypes.node.isRequired,
};

const mountWithReduxContext = (context) => (jsx, options) => baseMount(
github gor181 / react-notification-system-redux / dist / react-notification-system-redux.js View on Github external
var NotificationsWithContext = function NotificationsWithContext(props) {
  var Context = props.context || _reactRedux.ReactReduxContext;

  if (Context == null) {
    throw 'Please upgrade to react-redux v6';
  }

  return _react2['default'].createElement(
    Context.Consumer,
    null,
    function (otherProps) {
      var store = otherProps.store;

      return _react2['default'].createElement(Notifications, _extends({ store: store }, props));
    }
  );
};
github logux / redux / use-subscription.js View on Github external
var ReactReduxContext = require('react-redux').ReactReduxContext
var useContext = require('react').useContext
var useEffect = require('react').useEffect
var useState = require('react').useState

function add (store, subscriptions) {
  if (!store.subscriptions) store.subscriptions = { }
  if (!store.subscribers) store.subscribers = { }

  return Promise.all(subscriptions.map(function (i) {
    var subscription = i[0]
    var json = i[1]
    if (!store.subscribers[json]) store.subscribers[json] = 0
    store.subscribers[json] += 1
    if (store.subscribers[json] === 1) {
      var action = Object.assign({ type: 'logux/subscribe' }, subscription)
      store.subscriptions[json] = store.dispatch.sync(action)
github gor181 / react-notification-system-redux / lib / notifications.js View on Github external
var NotificationsWithContext = function NotificationsWithContext(props) {
  var Context = props.context || _reactRedux.ReactReduxContext;

  if (Context == null) {
    throw 'Please upgrade to react-redux v6';
  }

  return _react2['default'].createElement(
    Context.Consumer,
    null,
    function (otherProps) {
      var store = otherProps.store;

      return _react2['default'].createElement(Notifications, _extends({ store: store }, props));
    }
  );
};