React Native Debugger app version: v0.8.1
React Native version: 0.57.3
I am getting this error
It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function
It was working before I updated from 0.55.
This is how I create my store.
import { createStore, compose, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducers from '../reducers';
const store = createStore(
reducers,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
compose(applyMiddleware(thunk)),
);
export default store;
It works fine when I use Chrome to debug.
Please help, thanks
Instead of passing three arguments to the createStore function, you need to pass two (one of them is meant for a preloaded state, something we are not using here). To get around that, while still using the redux dev tools, you need to use the dev tools as the composer itself:
import { createStore, compose, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducers from '../reducers';
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
reducers,
composeEnhancer(applyMiddleware(thunk)),
);
export default store;
I realised this was the solution after digging around the redux library's, the debugger app's, and the dev tool's source code, and found this section: https://github.com/zalmoxisus/redux-devtools-extension#12-advanced-store-setup
I also saw an almost identical issue on github which I assume is yours, but I thought I would post the answer again here in case someone sees it here.
Hope this helps!
Because I had the same problem and wanted to use redux-devtools-extension the provided solution here could not be applied 1:1. How ever this one tuned out to do the job:
import { applyMiddleware, combineReducers, createStore } from 'redux';
import appConfigReducer from '../reducers/appConfigReducer';
import logger from 'redux-logger'
import { composeWithDevTools } from "redux-devtools-extension";
const rootReducer = combineReducers(
{config: appConfigReducer}
);
const composeEnhancers = composeWithDevTools({
// options like actionSanitizer, stateSanitizer
});
const configureStore = () => {
return createStore(rootReducer,
composeEnhancers(applyMiddleware(logger))
);
};
export default configureStore;
Related
Recently I ejected a Managed Workflow project and now I’m on Bare Workflow, things were going pretty good until now.
I was able to add native libraries and are working OK such as segment’s analytics-react-native and I’ve created a build for both iOS and android devices to run the dev client (instead of Expo Go). But now I wanted to add a composerEnhancer to see my store on react-native-debugger app and after setting it up I just get “no store found. Make sure to follow the instructions” on a browser tab.
import { combineReducers, createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import ReduxThunk from "redux-thunk";
const rootReducer = combineReducers({
auth: authReducer,
cart: cartReducer,
});
const store = createStore(
rootReducer,
composeWithDevTools(
applyMiddleware(ReduxThunk)
)
);
return (
<Provider store={store}>
<Navigation />
</Provider>
);
}
I tried same config in a Bare workflow with Exgo Go Client and it’s working fine. But I can’t make it work on Custom Dev Client, any thoughts?
Let say I have 2 plugins I want to use:
Bootstrap-Vue & Vue Analytics
I would import like so
import BootstrapVue from 'bootstrap-vue'
import VueAnalytics from 'vue-analytics'
How would I use them if one has parameters?
Is this correct?
Vue.use(BootstrapVue, VueAnalytics, {
id: 'UA-12345678-9'
});
Don't overthink it. Just call Vue.use twice.
Vue.use(BootstrapVue);
Vue.use(VueAnalytics, {
id: 'UA-12345678-9'
});
import BootstrapVue from 'bootstrap-vue'
import VueAnalytics from 'vue-analytics'
[BootstrapVue, VueAnalytics].forEach((x) => Vue.use(x));
This is what I usually use.
I will use:
const useArray = [Bootstrap-Vue, Vue Analytics];
useArray.forEach((item)=>{
Vue.use(item)
})
This question has been asked before but I cannot find a working solution so I'm taking the liberty to show my code in case I am missing something. I have a react native app and using redux. I have been using remote-redux-devtools for two months on this project now, but the tool stopped working all of a sudden. I receive a "SocketProtocolError" in the console and will paste that below as well as my code.
Redux store
import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "remote-redux-devtools";
import thunk from "redux-thunk";
import reducers from "../../State/reducers/index";
const composeEnhancers = composeWithDevTools({ realtime: true });
const store = createStore(
reducers,
{},
composeEnhancers(applyMiddleware(thunk))
);
export default store;
In my package.json file I am using "remote-redux-devtools": "^0.5.13"
This is the error I get in the console.
Any help would be greatly appreciated!
I fixed the same error when debugging an app on my phone by running:
adb reverse tcp:5678 tcp:5678
to allow the phone to connect to the devtools. Adjust the port number if using a different one. If you're running the app in an emulator on your computer, this probably won't help.
We are trying to use the same React components both in mobile (react-native) and in web (create-react-app).
It's is working out pretty well so far thanks to react-native-web (configuration below).
However react-native-vector-icons, which we use extensively in the react-native project, does not compile with react-native-web. This means any component which uses a component with vector-icons will also need a specific web version. Having web specific versions of components effects maintenance.
Is there a known way, without having to eject create-react-app configuration, to deal with 3rd parties such as react-native-vector-icons in web?
import {createIconSetFromIcoMoon} from "react-native-vector-icons";
import Font from './Font.json';
export default createIconSetFromIcoMoon(UbeyaFont);
Things we've thought of so far:
we are currently looking into two ideas:
Environment based import:
# Pseudo code:
# if mobile import this, otherwise import that.
We're not sure whether this kind of dynamic importing is possible
Webpack configuration which is injected into node_modules/react-scripts. Not elegant but with a gulp watch which we have anyway we can make sure the configuration is always there.
Any ideas or thoughts are appreciated.
Configuration:
We've built a new private NPM package which holds all the React components and by using gulp watch that copies the package to both the mobile and web projects we save the trouble of constantly npm publishing and yarning during development (the only drawback Webstorm's indexing process).
We ended up using a gulp script to overwrite webpack. The stages are:
1) Build replacement packages
We built a web version for each React Native 3rd party. For react-native-vector-icons it turned out to be quite simple:
import React from 'react';
export const Icon = (props) => <div className="material-icons"
style={{color:props.color}}>
{props.name}
</div>;
export default Icon;
2) Adjust the Webpack configuration
Using gulp we overwrite the create-react-app webpack configuration with:
resolve: {
modules: ...
alias: {
"babel-runtime": path.dirname(
require.resolve("babel-runtime/package.json")
),
"react-native": "#ourcompany/react-native-web",
"react-native-vector-icons": "#ourcompany/react-native-vector-icons",
...
The gulp task script:
gulp.task("copyWebpack", function() {
return gulp
.src(["package.json", "src/_webpack/*.js"])
.pipe(
gulp.dest(
path.resolve(pathWeb + "/node_modules/react-scripts/config")
)
);
});
Note:
Ejecting create-react-app's configuration is cleaner, however it means you'll need to maintain the configuration and we preferred leaving the configuration as is and overwriting it during the build process.
You'd notice we have overwritten react-native-web itself. More on this in the next optional step.
3) Extend react-native-web (optional)
If you are using components which react-native-web does not yet support, you would want to build packages for them and extend react-native-web so your web version will work. Simply create a new package #yourcompany/react-native-web and generate an index.js in which import the components that do exist in react-native-web and reference the ones you've built. Note that when we built our project react-native-web didn't have a FlatList or a SectionList and now (October 2018) it has both (Modal is still missing :-)).
import {
StyleSheet as _StyleSheet,
View as _View,
Text as _Text,
Image as _Image,
I18nManager as _I18nManager,
AsyncStorage as _AsyncStorage,
Platform as _Platform,
Linking as _Linking,
ActivityIndicator as _ActivityIndicator,
ListView as _ListView,
Modal as _Modal,
Picker as _Picker,
RefreshControl as _RefreshControl,
TextInput as _TextInput,
Touchable as _Touchable,
TouchableHighlight as _TouchableHighlight,
TouchableNativeFeedback as _TouchableNativeFeedback,
TouchableOpacity as _TouchableOpacity,
TouchableWithoutFeedback as _TouchableWithoutFeedback,
Dimensions as _Dimensions,
Animated as _Animated,
ScrollView as _ScrollView,
SafeAreaView as _SafeAreaView,
BackHandler as _BackHandler,
Switch as _Switch,
NetInfo as _NetInfo,
AppState as _AppState,
ColorPropType as _ColorPropType,
} from 'react-native-web';
import {SectionList as _SectionList} from './SectionList';
import {FlatList as _FlatList} from './FlatList';
import {Alert as _Alert} from './Alert';
import {WebView as _WebView} from './WebView';
import {Share as _Share} from './Share';
import {PermissionsAndroid as _PermissionsAndroid} from './PermissionsAndroid';
import {ActionSheetIOS as _ActionSheetIOS} from './ActionSheetIOS';
import {ToastAndroid as _ToastAndroid} from './ToastAndroid';
export const StyleSheet = _StyleSheet;
export const View = _View;
export const Text = _Text;
export const Image = _Image;
export const I18nManager = _I18nManager;
export const AsyncStorage = _AsyncStorage;
export const Platform = _Platform;
export const Linking = _Linking;
export const ActivityIndicator = _ActivityIndicator;
export const ListView = _ListView;
export const Modal = _Modal;
export const Picker = _Picker;
export const RefreshControl = _RefreshControl;
export const TextInput = _TextInput;
export const Touchable = _Touchable;
export const TouchableHighlight = _TouchableHighlight;
export const TouchableNativeFeedback = _TouchableNativeFeedback;
export const TouchableOpacity = _TouchableOpacity;
export const TouchableWithoutFeedback = _TouchableWithoutFeedback;
export const Dimensions = _Dimensions;
export const Animated = _Animated;
export const ScrollView = _ScrollView;
export const SafeAreaView = _SafeAreaView;
export const BackHandler = _BackHandler;
export const Switch = _Switch;
export const NetInfo = _NetInfo;
export const AppState = _AppState;
export const Alert = _Alert;
export const Share = _Share;
export const WebView = _WebView;
export const PermissionsAndroid = _PermissionsAndroid;
export const ActionSheetIOS = _ActionSheetIOS;
export const ToastAndroid = _ToastAndroid;
export const SectionList = _SectionList;
export const FlatList = _FlatList;
export const ColorPropType = _ColorPropType;
This is my code snippet below :
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import devTools from 'remote-redux-devtools';
import StockApp from '../reducers';
// create a store that has redux-thunk middleware enabled
const createStoreWithMiddleware = applyMiddleware(
thunk
)(createStore);
alert("inside production");
export default function configureStore() {
return createStoreWithMiddleware(StockApp);
}
Whenever i try to import remote-redux-devtools it gives me below screen
in case i try to remove remote-redux-devtools import statement everything goes well , please suggest or point out what can be cause when i specify redux dev tool in
as the picture,you should ctrl+c end the server, and re-start, npm run start --reset-cache