So I have coded a map using react-leaflet and I and I am trying to add gradient when the user clicks on the map but unfortunately, it's not working
Here is the code
const style = (feature: any) => {
return {
fillColor:
feature?.properties.StateName === stateName ? "red" : "green",
// ? linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,41,121,1) 39%, rgba(17,68,87,1) 65%, rgba(0,212,255,1) 81%)
// : linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(121,111,9,1) 35%, rgba(0,212,255,1) 100%),
weight: 1,
opacity: 1,
color:
feature?.properties.StateName === stateName ? "#FFFFFF" : "#252117",
border: "0.1px solid #000000",
};
};
// passing to component like this
<GeoJSON
key={index}
data={boundary}
style={style}
onEachFeature={eachFeature}
/>
How can I add a gradient?
Note: Red and green colors are working as per the need but when I switch them with the desired gradient I get a black map