I am trying to use svg images that I can pass as props (I will be using an array of svg images). I am using gatsby-plugin-react-svg which allows me to import the svg and use it as a component. This works but I can't pass the svg images as props or reference them in an array this way. While looking for a solution I have seen many suggestions to import the svg and then use it as the src in an img tag. This would work perfectly for me but it doesn't work when I try it. Do I need a different plugin to use svg images this way?
This works (which also means that my path is correct):
import CurrentSelected from "../assets/markers/current_selected.svg"
<Layout>
<CurrentSelected />
</Layout>
These don't work (but is what I need to use):
import CurrentSelected from "../assets/markers/current_selected.svg"
<Layout>
<img src={CurrentSelected} />
</Layout>
OR
<Layout>
<img src={require("../assets/markers/current_selected.svg")} />
</Layout>
While looking for a solution, I have seen this suggested as a solution but it doesn't work in my project. Can anyone help me to render my images this way (or any other way that's not using the svg as a component)?