How to use the react-redux.createProvider 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 flow-typed / flow-typed / definitions / npm / react-redux_v5.x.x / flow_v0.68.0-v0.84.x / test_Provider.js View on Github external
it('should give an error when the store is missing', () => {
    // $ExpectError
    ;

    // Also for custom providers
    const CustomProvider: Provider<*, *, *> = createProvider("ikea");

    // $ExpectError
    ;
  });
});
github flow-typed / flow-typed / definitions / npm / react-redux_v5.x.x / flow_v0.63.0-v0.67.x / test_Provider.js View on Github external
// @flow
import React from "react";
import { Provider, createProvider } from "react-redux";

// $ExpectError
; // missing store

const CustomProvider: Provider<*, *> = createProvider("ikea");

// $ExpectError
; // missing store
github flow-typed / flow-typed / definitions / npm / react-redux_v5.x.x / flow_v0.53.x-v0.53.x / test_Provider.js View on Github external
// @flow
import React from "react";
import { Provider, createProvider } from "react-redux";

// $ExpectError
; // missing store

const CustomProvider: Provider<*, *> = createProvider("ikea");

// $ExpectError
; // missing store
github appbaseio / reactivesearch / packages / native / src / components / basic / ReactiveBase.js View on Github external
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,
github sergey-su / react-inversify / src / index.tsx View on Github external
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();
github theKashey / restate / packages / react-redux-restate / src / reprovide.js View on Github external
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() {
github Coding / WebIDE-Frontend / app / extensions / PluginApp.ext.js View on Github external
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 }
    )
})
github theKashey / restate / packages / react-redux-restate / src / restate.js View on Github external
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});
github WordPress / gutenberg / edit-template / index.js View on Github external
export function initializeEditor( id, post, settings ) {
	const target = document.getElementById( id );

	const TemplateProvider = createProvider( 'edit-template' );

	render(
		
			
				
			
		,
		target
	);
}
github samuelmaddock / metastream / app / renderer / lobby / redux.tsx View on Github external
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;
}