You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing some re-rendering issues and unsure what could be causing this.
When I visit settings page (It load shops configuration from server), not sure why it for a moment of time renders previously active page, and then immediately it renders the page it should... (Attaching video below).
Screen.Recording.2025-01-31.at.11.37.15.mov
The settings page:
exportconstloader=async({ request }: LoaderFunctionArgs)=>{constdata=awaitauthenticate.admin(request);constconfig=awaitprisma.config.findFirst({where: {shop: data.session.shop,},});return{brandColor: config?.brandColor,iconColor: config?.iconColor,icon: config?.icon,};};exportconstaction=async({ request }: ActionFunctionArgs)=>{constformData=awaitrequest.clone().formData();const{ session }=awaitauthenticate.admin(request);constbrandColor=formData.get("brandColor")asstring;consticonColor=formData.get("iconColor")asstring;consticon=formData.get("icon")asstring;try{constconfig=awaitprisma.config.findFirst({where: {shop: session.shop},});if(!config){thrownewError(`Config not found....`);}awaitprisma.config.update({where: {id: config.id},data: {
brandColor,
iconColor,
icon,},});constresult={success: true,message: "Settings saved!",};returnresult;}catch(error){constresult={success: false,message: "Error saving settings.",};console.error(result.message,error);returnresult;}};exportdefaultfunctionSettingsPage(){constfetcher=useFetcher<typeofaction>();useEffect(()=>{if(fetcher.state!=="idle"||!fetcher.data)return;shopify.toast.show(fetcher.data.message,{duration: 2500,isError: !fetcher.data.success,});},[fetcher.data,fetcher.state]);constsettingsData=useLoaderData<typeofloader>();const[brandColor,setBrandColor]=useState<string>(settingsData.brandColor||"#111",);const[iconColor,setIconColor]=useState<string>(settingsData.iconColor||"#111",);const[iconStyle,setIconStyle]=useState<AvailableIcons>((settingsData.iconasAvailableIcons)||"star2",);constwasChanged=useMemo(()=>{return(settingsData.brandColor!==brandColor||iconColor!==settingsData.iconColor||iconStyle!==settingsData.icon);},[brandColor,iconColor,iconStyle,settingsData.brandColor,settingsData.icon,settingsData.iconColor,]);consthandleClick=async()=>{if(fetcher.state==="submitting")return;fetcher.submit({icon: iconStyle, iconColor, brandColor },// Data to send{method: "post"},// Default is the current route's action);};return(<Suspensefallback="Loading..."><Page><TitleBartitle="Settings"/><Layout><Layout.Section><Card><Textvariant="headingSm"as="h2">ThemeSettings</Text><divclassName="mb-5"></div><FormLayout><BoxborderColor="border"borderWidth="0165"padding="150"borderRadius="300"><InlineGridgap="400"columns={3}><PopoverColorPickerhexColor={brandColor}setHexColor={setBrandColor}label="Branding Color"/><PopoverColorPickerhexColor={iconColor}setHexColor={setIconColor}label="Icon Color"/></InlineGrid><InlineGridgap="100"columns={3}><PopoverReviewIconPickerlabel={"Icon Style"}icon={iconStyle}setIcon={setIconStyle}fill={iconColor}/></InlineGrid></Box></FormLayout></Card><PageActionsprimaryAction={{content: "Save",loading: fetcher.state==="submitting",disabled: !wasChanged,onAction: handleClick,}}/></Layout.Section></Layout></Page></Suspense>);}
What could be causing such behaviour for Settings Page ?
Problem
I am experiencing some re-rendering issues and unsure what could be causing this.
When I visit settings page (It load shops configuration from server), not sure why it for a moment of time renders previously active page, and then immediately it renders the page it should... (Attaching video below).
Screen.Recording.2025-01-31.at.11.37.15.mov
The settings page:
What could be causing such behaviour for
Settings Page?