I wrote this code in next.js but I encountered an error. The error says "NextJS - ReferenceError: window is not defined". can you help me how can i fix it
function IconWeatherComponent({icon}) {
let [svg, setSvg] = useState('');
useEffect(() => {
const setIcon = () => {
if (icon === '01d') {
setSvg('day.svg')
}
if (icon === '01n') {
setSvg('night.svg')
}
setIcon();
}, [icon])
return (
<div>
<img src={`${window.location.origin}/weather-icons/${svg}`} width="70" height="70" alt=""/>
</div>
);
}
export default IconWeatherComponent