Map an object of svg in react native?

Viewed 47

I have this png's images:

import { alergology, cardiology, dermatology, endocrinology, gynecology } from '@/constants/images'

Made this object:

const images: IObjectKeys = {
  Alergología: alergology,
  Cardiología: cardiology,
  Dermatología: dermatology,
  Endocrinología: endocrinology,
  Ginecología: gynecology,
};

And render like this :

export const addingImgToSpecialties = (specialties: Speciality[]) =>
  specialties.map((specialty) => {
    const { name } = specialty;
    return {
      ...specialty,
      img: images[name],
    };
  });

Now I need to to change pngs to svgs , this is what I am trying to do 1)Import the svg 2)Then add it to value.

Already installed react-native-svg and used it in other views without mapping.

import Alergology from '@assets/images/specialties/alergologia.svg';

const images: IObjectKeys = {
  Alergología: Alergology,
  Cardiología: Cardiology,
  Dermatología: Dermatology,
  Endocrinología: Dndocrinology,
  Ginecología: Dynecology,
};

but in this case, it crashes the application, I get this error

[Unhandled promise rejection: TypeError: JSON.stringify cannot serialize cyclic structures.]

How I should do this ?

0 Answers
Related