Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor. ShowQuestion apply react.memo #65

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Redirection from "./pages/RedirectionPage";
import OpenExternalBrowser from "./OpenExternalBrowser";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import "./App.css";
function App() {
export default function App() {
return (
<RecoilRoot>
<div className="App">
Expand All @@ -44,5 +44,3 @@ function App() {
</RecoilRoot>
);
}

export default App;
6 changes: 5 additions & 1 deletion src/components/ShowQuestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function ShowQuestion({
navigatehobby();
}
};

return (
<Fragment>
{showQuestions[QuestionNum][0] && (
Expand Down Expand Up @@ -56,4 +57,7 @@ function ShowQuestion({
);
}

export default ShowQuestion;
// React.memo 적용
export const MemoizedShowQuestion = React.memo(ShowQuestion);

export default MemoizedShowQuestion;
16 changes: 1 addition & 15 deletions src/pages/Match.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,7 @@ function Match() {
setMatchState={setMatchState}
setMatchPageResult={setMatchPageResult}
/>
{/* <div className="match-header">
<div>
<img
className="logo-img"
src={process.env.PUBLIC_URL + `assets/logowhite.png`}
alt="로고"
onClick={handleMatchLogo}
/>
</div>
<div className="match-point-remaining">
잔여포인트
<img src={process.env.PUBLIC_URL + `assets/point.svg`} alt="cost" />
{MatchState.balance}
</div>
</div> */}

<div className="matchcontent">
<div className="match-title">
<div className="match-title-text">Matching</div>
Expand Down
46 changes: 2 additions & 44 deletions src/pages/Matchresult.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,7 @@ function Matchresult() {
console.error("Error during match request", error);
}
};
// const handleMatchLogo = () => {
// setMatchState({
// selectedMBTI: ["X", "X", "X", "X"],
// selectedCategory: [],
// point: 500,
// balance: null,
// isUseOption: [false, false, false, false],
// formData: {
// mbti_option: "",
// contact_frequency_option: "",
// hobby_option: [],
// age_option: "",
// match_code: "",
// no_same_major_option: false,
// ai_option_count: 0,
// },
// });
// setMatchResult({
// major: null,
// age: null,
// hobby: [],
// mbti: null,
// song: null,
// contactFrequency: null,
// contactId: null,
// word: null,
// });
// navigate("/CodeReader");
// };

return (
<div>
<div className="container">
Expand All @@ -104,21 +76,7 @@ function Matchresult() {
setMatchState={setMatchState}
setMatchPageResult={setMatchResult}
/>
{/* <div className="match-header">
<div>
<img
className="logo-img"
src={process.env.PUBLIC_URL + `assets/logowhite.png`}
alt="로고"
onClick={handleMatchLogo}
/>
</div>
<div className="match-point-remaining">
잔여포인트
<img src={process.env.PUBLIC_URL + `assets/point.svg`} alt="cost" />
{MatchState.balance}
</div>
</div> */}

{MatchResult.generatedCode === 2002 ? (
<div className="matchresult-content">
<div style={{ textAlign: "center" }}>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ProfileBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useRecoilState } from "recoil";
import { selectedMBTIState, userState } from "../Atoms";
import { useNavigate } from "react-router-dom";
import AgeMaker from "../components/AgeMaker";
import ShowQuestion from "../components/ShowQuestion";
import MemoizedShowQuestion from "../components/ShowQuestion";

const ProfileBuilder = () => {
const navigate = useNavigate();
Expand Down Expand Up @@ -103,7 +103,7 @@ const ProfileBuilder = () => {
/>
</div>
{questions.map((_, index) => (
<ShowQuestion
<MemoizedShowQuestion
key={index}
showQuestions={showQuestions}
QuestionNum={index}
Expand Down