This is my component:
export default function ImageUpload({ onSuccess, children}) {
let value = '';
const onUpload = async (element) => {
element = element.target.files;
let response;
// Call endpoint to upload the file
value = element[0].name;
return onSuccess(response.url);
};
return <div>
<div >
{children}
<input type="file" id="upload" onChange={onUpload.bind(this)} />
</div>
<span>{value}</span>
</div>;
}
I would like to print inside the span the name of the file chosen from the user. I use redux for the state, but this information is not something that belongs to the state. This way does not work, could someone explain me why?
UPDATE Since looks like there is no way to achieve this without state my question is about the best approach: Use Redux also if I don't need this value outside the component or use the internal state of the component but ending to have both Redux and this state?