@@ -413,17 +413,22 @@ export const useContractorOnboarding = ({
413413 [ stepFields . select_country , internalCountryCode , employmentCountryCode ] ,
414414 ) ;
415415
416+ // memoize file conversion to avoid re-converting the file on every render
417+ // noticed performance issues when not doing memoizing individually
418+ const convertedIr35File = useMemo ( ( ) => {
419+ if ( ! ir35File ?. content ) return null ;
420+ return dataURLtoFile ( ir35File . content as unknown as string , ir35File . name ) ;
421+ } , [ ir35File ?. content , ir35File ?. name ] ) ;
422+
416423 const basicInformationInitialValues = useMemo ( ( ) => {
417424 const initialValues = {
418425 provisional_start_date : provisionalStartDate ,
419426 ...onboardingInitialValues ,
420427 ...employmentBasicInformation ,
421428 ir35 : employment ?. contract_details ?. ir_35 ,
422429 saudi_nationality_status : employment ?. contract_details ?. nationality ,
423- ...( ir35File ?. content && {
424- ir35_sds_file : [
425- dataURLtoFile ( ir35File . content as unknown as string , ir35File . name ) ,
426- ] ,
430+ ...( convertedIr35File && {
431+ ir35_sds_file : [ convertedIr35File ] ,
427432 } ) ,
428433 } ;
429434
@@ -433,7 +438,7 @@ export const useContractorOnboarding = ({
433438 employmentBasicInformation ,
434439 employment ?. contract_details ?. ir_35 ,
435440 employment ?. contract_details ?. nationality ,
436- ir35File ,
441+ convertedIr35File ,
437442 stepFields . basic_information ,
438443 ] ) ;
439444
0 commit comments