I use React and Redux, webSocket to work with some server-side events.
I can send actions from a component by assigning a function to a dispatcher using a function mapDispatchToProps().
But what about triggering outside the components? For example, with a received webSocket event.
A call store.dispatchfrom another script will return a reference error (sending unspecified), even if the repository is correctly imported
Is there any way to do this?
Here is my app store configuration:
import { createStore, combineReducers, applyMiddleware, compose } from 'Redux'
import thunk from '../../node_modules/redux-thunk/src/index'
import rootReducer from '../reducers/index'
const configureStore = (initialState) => {
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(thunk),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
)
}
export default configureStore
here is the entry point to the application where the repository is created:
import React, { Component } from 'React'
import { render } from 'ReactDOM'
import { Provider } from 'ReactRedux'
import { Router, hashHistory } from 'ReactRouter'
import actions from './actions/actions'
import configureStore from './store/configureStore'
import routes from './routes'
const store = configureStore()
console.log('store log', store)
window.storeDebug = store.getState()
render(
<Provider store={store}>
<Router history={hashHistory} routes={routes} />
</Provider>,
document.getElementById('container')
)