I’m working on a next.js app and I have two pages that have the same code. Here’s a snippet from pages/books/[cid]
export default function Book() {
const [sourceType] = useState("book")
useEffect(() => {
dispatch(changeActiveSource(`${sourceType}s`));
dispatch(
fetchFullData({ url: `http://localhost:1338/${sourceType}-series`,
type: `${sourceType}s` })
);
}, []);
}
Note const [sourceType] = useState("book")
I’m not using setSourceType
is that ok?
And I was thinking of duplicating that page in pages/courses/[cid]
. I know about templates (but this is not a template). Is it recommended to duplicate the page or is there a pattern to follow for this?