I'm building an app with a mini forum using Next.js with Incremental Static Regeneration for my school project but have ran into some trouble regarding prop drilling. I have this prop flow that goes getStaticProps => backgroundLayout => mainPage => other page components
I'm thinking of using context API to solve the issue but the I'm worried that the context API will get overwhelmed and possibly slow down the app as the forum grows. I have learned to use the context API just for global context and the forum is just a small part of the app. However, there are many more times that I need to implement prop drilling (like the code below) with tons of data using SSR and ISR so again, context API might bottleneck. What should one opt to do? Keep with prop drilling or use Context API?
import React from "react";
import styles from "./index.module.css";
import Layout from "../../components/_layout";
import { GetStaticProps } from "next";
import dbExecute from "../../_operations/db/db";
import OuterForumLeft from "../../components/school-forum/left";
import OuterForumRight from "../../components/school-forum/right";
interface Props {
data: {
question_id: number;
question_header: string;
question_body: string;
question_timestamp: string;
account_first_name: string;
account_last_name: string;
section_grade: string;
section_strand: string;
};
}
export const SchoolForum: React.FC<Props> = ({ data }) => {
return (
<>
<section className={styles.outermostForumSection}>
// passes again
<OuterForumLeft />
<OuterForumRight />
</section>
</>
);
};
const SchoolForumPage: React.FC<Props> = ({ data }) => {
return (
<>
<Layout page={<SchoolForum data={data} />} />
</>
);
};
export default SchoolForumPage;
export const getStaticProps: GetStaticProps = async () => {
const sql: string = `SELECT * FROM account_table`;
const [sqlData] = await dbExecute(sql);
return {
props: {
data: sqlData,
},
};
};