The full error message:
Invariant Violation: Could not find "store" in either the context or props of "Connect(Portfolio)". Either wrap the root component in a , or explicitly pass "store" as a prop to "Connect(Portfolio)".
Not sure why I'm getting this error in my Jest tests as my app is working and I can change my state with dispatch actions.
index.js
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, applyMiddleware, compose } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import reducer from './reducer'
import App from './App'
const element = document.getElementById('coinhover');
const store = createStore(reducer, compose(
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
));
ReactDOM.render(
<Provider store={ store }>
<App />
</Provider>, element);
Portfolio component
import React from 'react'
import { connect } from 'react-redux'
import SocialMediaFooter from '../common/SocialMediaFooter'
import AssetsTable from '../assetsTable/AssetsTable'
import local_coins from '../../coins.json'
import * as api from '../../services/api'
const mapStateToProps = ({ portfolio }) => ({
portfolio
});
let localCoins = local_coins;
class Portfolio extends React.Component {
constructor(props) {
super(props)
this.state = {
loading: true,
assets: props.portfolio,
total: 0
};
}
componentDidMount() {
this.setState({ loading: false });
}
render() {
const assets = this.state.assets;
const total = this.state.total;
return (
<div className="app-bg">
<section className="portfolio">
<header>
<h1><span className="plus">+</span>COINHOVER</h1>
<h2>Watch your cryptocurrency asset balances in once place.</h2>
<em className="num">${ total }</em>
</header>
{ this.state.loading ? (
<div className="loading">
<div className="loader"></div>
<span>Loading coin data...</span>
</div>
) : (
<AssetsTable assets={ assets }/>
)}
<SocialMediaFooter />
</section>
</div>
)
}
}
export default connect(mapStateToProps, null)(Portfolio)