The example with-cookie-example uses getInitialProps, how to use getServerSideProps in that case?
// /components/withAuth.js
export const withAuthSync = WrappedComponent => {
const Wrapper = props => {
return <WrappedComponent {...props} />
}
Wrapper.getInitialProps = async ctx => {
const token = auth(ctx)
const componentProps =
WrappedComponent.getInitialProps &&
(await WrappedComponent.getInitialProps(ctx))
return { ...componentProps, token }
}
return Wrapper
}
My page with this wrapper
// /pages/home.js
import React from 'react';
import {withAuthSync} from '../containers/hocs/withAuth';
const Home = (props) => {
return (
<div>
Home Page
</div>
);
};
export async function getServerSideProps(ctx) {
const data = await doSomething();
return {
props: {...data}
};
};
export default withAuthSync(Home);
I have this error
You can not use getInitialProps with getServerSideProps. Please remove getInitialProps. /home
What's with that title? 馃
Please stop double posting and ignoring the issue template.
Duplicate of https://github.com/zeit/next.js/discussions/11317