I am wondering why React does not display images with characters in the name such as: ą
, ć
, ż
, ł
etc ? In my case they are Polish characters.
I have all filenames stored as path in MongoDB database then display them using map
function. The status of all images is stored in Redux. All images are placed in the public
directory. When I copy the file name and paste it to the URL, the browser displays the photo normally, but React itself no longer does. What is the cause of this behavior ? What I tried was trying to pass the filename through the encodeURI()
function, e.g. <img src={encodeURI(file.name) />
, but with no positive result.
{video.map((file) => (
<li
key={file.name}
>
<img
src={file.cover}
alt={file.name}
/>
</li>
))}
Aciton from Redux:
export const moviesList =
(keyword = '') =>
async (dispatch, getState) => {
try {
dispatch({ type: VIDEO_LIST_REQUEST })
const { data } = await axios.get(
`/api/video?keyword=${keyword}`,
config
)
dispatch({
type: VIDEO_LIST_SUCCESS,
payload: data,
})
} catch (error) {
...
})
}
}