@@ -4,30 +4,29 @@ import Button from "../ui/Button";
44import useResumeStore from "../../store/useResumeStore" ;
55import { useResumeActions } from "../../store/useResumeActions" ;
66import { FaX , FaPlus } from "react-icons/fa6" ;
7+ import { memo , useCallback , useMemo } from "react" ;
78
89const ScrollableModal = ( { showPreview, setShowPreview } ) => {
910 const navigate = useNavigate ( ) ;
1011 const { resumeInsights } = useResumeStore ( ) ;
1112 const { addSkill, removeSkill } = useResumeActions ( ) ;
1213
13- const handleContinue = ( ) => {
14+ const handleContinue = useCallback ( ( ) => {
1415 setShowPreview ( false ) ;
1516 navigate ( "result" ) ;
16- } ;
17+ } , [ ] ) ;
1718
18- const handleAddSkill = ( type ) => {
19- const newSkill = prompt ( `Enter a new ${ type } skill:` ) ;
20- if ( newSkill ) {
21- addSkill ( type , newSkill . trim ( ) . toLowerCase ( ) ) ;
22- }
19+ const handleAddSkill = useCallback (
20+ ( type ) => {
21+ const newSkill = prompt ( `Enter a new ${ type } skill:` ) ;
22+ if ( newSkill ) {
23+ addSkill ( type , newSkill . trim ( ) . toLowerCase ( ) ) ;
24+ }
2325
24- return ;
25- } ;
26-
27- // const {
28- // skills: { technical, soft },
29- // summary,
30- // } = resumeInsights;
26+ return ;
27+ } ,
28+ [ addSkill ]
29+ ) ;
3130
3231 const summary = resumeInsights ?. summary ;
3332 const technical = resumeInsights ?. skills ?. technical ;
@@ -127,4 +126,11 @@ const ScrollableModal = ({ showPreview, setShowPreview }) => {
127126 ) ;
128127} ;
129128
130- export default ScrollableModal ;
129+ const areEqual = ( prevProps , nextProps ) => {
130+ return (
131+ prevProps . showPreview === nextProps . showPreview &&
132+ prevProps . setShowPreview === nextProps . setShowPreview
133+ ) ;
134+ } ;
135+
136+ export default memo ( ScrollableModal , areEqual ) ;
0 commit comments