Closed jonathandion closed 8 years ago
@jonathandion Hmm, I've never seen this issue. Do you have an example project you can share?
Hey @adjohnson916, I think there is a conflict with my node_modules. I tried in another project and it's working fine. Sorry for that. Now I have another problem, how do I have access to the get
method ?
I have access to my firedux.data
inside my state but not all the api methods. What i'm doing wrong? thanks.
@jonathandion Glad you figured it out - thanks for reporting.
The API methods are available on the firedux instance, not in the state. If you have some example code, maybe I can help.
Thanks for the help !
There is my code main.js
'user strict'
// @imports
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { Router, Route, browserHistory } from 'react-router'
import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
// reducers
import order from './reducers/order.js'
import inventory from './reducers/inventory.js'
import Firedux from 'firedux'
import { createStore, applyMiddleware, combineReducers } from 'redux'
import thunk from 'redux-thunk'
// helpers
import "babel-polyfill";
// components
import Store from './components/Store'
import StorePicker from './components/main/StorePicker'
import NotFound from './components/common/NotFound'
const firedux = new Firedux({
url: 'https://fishes-store.firebaseio.com/'
})
const reducer = combineReducers({
firedux: firedux.reducer(),
order,
inventory,
routing: routerReducer
})
const store = applyMiddleware(
thunk
)(createStore)(reducer)
firedux.dispatch = store.dispatch
const history = syncHistoryWithStore(browserHistory, store)
/*
Routes
*/
const routes = (
<Provider store={store}>
<Router history={history}>
<Route path="/" component={StorePicker}/>
<Route path="/store/:storeId" component={Store}/>
<Route path="*" component={NotFound}/>
</Router>
</Provider>
)
// render the app
render(routes, document.getElementById('main'))
Now I want to access firedux instance
inside my Store component.
Store.js
class Store extends React.Component {
constructor(props) {
super(props)
console.log(this.props.firedux) // firedux.data is accessible here
// I would like to access the firedux API here.
}
render() {
}
}
const mapStateToProps = (state) => {
return {
fishes : state.inventory,
order : state.order,
firedux : state.firedux
}
}
Store = connect(mapStateToProps)(Store)
export default Store;
Hey, there is a problem with your dependencies. Lodash is there in your node_modules but when you try to compile I have a lot of 'Cannot find module' errors.