I'm trying to hook my next.js web app with redux by using 'next-redux-wrapper' HOC.
I was able to fetch data from server from getInitialProps function but after wrapping my _app.js with next-redux-wrapper the getInitialProps functions doesn't seem to work.
What do I do wrong here and how can I fix it?
import React from 'react'
import fetch from 'isomorphic-unfetch'
import { connect } from 'react-redux'
import { getItems } from '../../store/actions/itemAction'
const Index = (props) => {
console.log(props)
return ()
}
Index.getInitialProps = async () => {
let items
await fetch('http://localhost:5000/item')
.then(res => res.json())
.then(data => { items = data })
.catch(err => console.log(err))
return { items }
}
const mapStatetoProps = state => ({
item: state.item,
})
export default connect(mapStatetoProps, null)(Index)