Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should give an error when the store is missing', () => {
// $ExpectError
;
// Also for custom providers
const CustomProvider: Provider<*, *, *> = createProvider("ikea");
// $ExpectError
;
});
});
// @flow
import React from "react";
import { Provider, createProvider } from "react-redux";
// $ExpectError
; // missing store
const CustomProvider: Provider<*, *> = createProvider("ikea");
// $ExpectError
; // missing store
// @flow
import React from "react";
import { Provider, createProvider } from "react-redux";
// $ExpectError
; // missing store
const CustomProvider: Provider<*, *> = createProvider("ikea");
// $ExpectError
; // missing store
import React, { Component } from 'react';
import { createProvider } from 'react-redux';
import { Container } from 'native-base';
import Appbase from 'appbase-js';
import configureStore, { storeKey } from '@appbaseio/reactivecore';
import types from '@appbaseio/reactivecore/lib/utils/types';
import ThemeProvider from '../../theme/ThemeProvider';
import theme from '../../theme';
/* use a custom store key so reactivesearch does not interfere
with a different redux store in a nested context */
const Provider = createProvider(storeKey);
// for network debugging while development
// GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
class ReactiveBase extends Component {
constructor(props) {
super(props);
this.type = props.type ? props.type : '*';
const credentials
= props.url && props.url.trim() !== '' && !props.credentials ? null : props.credentials;
const config = {
url: props.url && props.url.trim() !== '' ? props.url : 'https://scalr.api.appbase.io',
app: props.app,
import { connect as reduxConnect, Provider as ReduxProvider, Store as ReduxStore, createProvider as createReduxProvider, DispatchProp, InferableComponentEnhancerWithProps } from "react-redux";
import { createStore, Action } from "redux";
import * as React from 'react';
export { ChangeNotification, ChangeNotificationCallback, returntypeof, ReactDIProvider as Provider, ProviderProps, createProviderClass, Connect };
export const connect: Connect = connectImpl;
// react-redux typings are missing this advanced function.
// it has to be declated manually.
declare module "react-redux" {
export function createProvider(storeKey: string): typeof ReduxProvider;
};
const storeName = "react-di-store";
const ReduxProviderWithCustomName = createReduxProvider(storeName);
type ChangeNotificationCallback = () => void;
class ChangeNotification {
private _posted: boolean = false;
private _callbacks: Set = new Set();
constructor() {
this.post = this.post.bind(this);
this.subscribe = this.subscribe.bind(this);
this.unsubscribe = this.unsubscribe.bind(this);
}
post(immediately = false): void {
if (immediately) {
this._notifyAll();
const reprovide = (newName, oldName = 'store') => {
const storeKey = oldName;
const restateKey = newName;
const Provider = createProvider(restateKey);
class Reprovider extends Component {
static contextTypes = {
[storeKey]: PropTypes.any,
};
static propTypes = {
children: PropTypes.node,
};
constructor(props, context) {
super();
this.store = props[storeKey] || context[storeKey];
}
render() {
export const createAdvancedProviderAndConnect = (storeKey) => ({
Provider: createProvider(storeKey),
connect: (mapStateToProps, mapDispatchToProps) => connectAdvanced(
(dispatch, options) => (state, props) => {
const selectedState =
typeof mapStateToProps === 'function' || !!mapStateToProps
? mapStateToProps(state)
: state
return {
...selectedState,
...props,
...mapDispatchToProps(dispatch)
}
},
{ storeKey }
)
})
const restate = (baseStores, composeState, routeDispatch, options = nullFn) => WrappedComponent => {
if(options && typeof options !== 'function') {
throw new Error('react-redux-restate: options should be an option')
}
const basicOptions = options({});
const storeKey = basicOptions.storeKey || 'store';
const restateKey = basicOptions.restateKey || 'store';
const Provider = createProvider(restateKey);
const contextTypes = {
[storeKey]: PropTypes.any,
};
Object.keys(baseStores).forEach(key => {
const value = baseStores[key];
if (typeof value === 'string') {
contextTypes[value] = PropTypes.any;
}
});
const ignoredProps = {};
const deeperProps = basicOptions.deeperProps || [];
(basicOptions.ignoreProps || []).forEach(prop => {ignoredProps[prop] = undefined});
export function initializeEditor( id, post, settings ) {
const target = document.getElementById( id );
const TemplateProvider = createProvider( 'edit-template' );
render(
,
target
);
}
const Wrapper: any = (props: any, context: any) => (
);
Wrapper.displayName = `WrappedConnect(${ConnectedComponent.displayName})`;
Wrapper.contextTypes = {
[storeName]: PropTypes.object
};
return Wrapper;
};
}
export default customConnect;
export const NetProvider = createProvider(NET_STORE_NAME) as typeof Provider;
export function createNetStore(opts: NetMiddlewareOptions): Store {
const middleware: Middleware[] = [
netRpcMiddleware(opts),
netSyncMiddleware(opts),
usersMiddleware(opts),
sessionMiddleware(opts),
thunkMiddleware
];
const store = createStore(netReducer, applyMiddleware(...middleware));
return store;
}