Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
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(
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));
}
);
};
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)
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));
}
);
};