Skip to content

Commit

Permalink
front: fix rs image blinking when changing in stdcm
Browse files Browse the repository at this point in the history
Signed-off-by: theocrsb <[email protected]>
  • Loading branch information
theocrsb committed Nov 28, 2024
1 parent 003ece7 commit deac2f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const RollingStock2Img = ({ rollingStock }: RollingStock2ImgProps) => {
getRollingStockImage();
}, [rollingStock]);

return <img src={imageUrl || ''} alt={rollingStock?.name || 'defaultImg'} loading="lazy" />;
if (!imageUrl) return null;

return <img src={imageUrl} alt={rollingStock?.name} />;
};

export default React.memo(RollingStock2Img);
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ export const useStoreDataForRollingStockSelector = () => {
const rollingStockId = useSelector(getRollingStockID);
const rollingStockComfort = useSelector(getRollingStockComfort);

const { data: rollingStock } = osrdEditoastApi.endpoints.getRollingStockByRollingStockId.useQuery(
{
rollingStockId: rollingStockId!,
},
{
skip: !rollingStockId,
}
);
const { currentData: rollingStock } =
osrdEditoastApi.endpoints.getRollingStockByRollingStockId.useQuery(
{
rollingStockId: rollingStockId!,
},
{
skip: !rollingStockId,
}
);

return {
rollingStockId,
Expand Down

0 comments on commit deac2f4

Please sign in to comment.