Factor out new article vs edit article pages
cirosantilli opened this issue · comments
They are mostly copy paste now:
- https://github.com/reck1ess/next-realworld-example-app/blob/66003772a42bf71c7b2771119121d4c9cf4b07d4/pages/editor/%5Bpid%5D.tsx
- https://github.com/reck1ess/next-realworld-example-app/blob/66003772a42bf71c7b2771119121d4c9cf4b07d4/pages/editor/new.tsx
I'm giving it a shot but stuck at some point, I wanted to do a this.props
from getInitialProps
to check new
at:
import ArticleEditor from "../../components/editor/ArticleEditor";
export default function PublishArticleEditor() {
return (
<ArticleEditor new />
);
};
but I can't use this.props
from there. Thinking is hard.
OK, I managed it as in: ourbigbook/ourbigbook@8c05857 by creating a function that returns a function.
I also made it use ArticleAPI.update
in the component rather than raw axios.
Now I'm going to convert to the better new API getStaticProps + getStaticPaths since my repo is a fullstack integration.