I created the below custom component to upload files from retool to the backend,
When I select a file, and then try to inspect the component value, I am not getting anything
{{ customComponent1.model.file }} -> {}
Model:
{ file: {} }
<style>
body {
margin: 0;
}
</style>
<script
src="https://cdn.tryretool.com/js/react.production.min.js"
crossorigin
></script>
<script
src="https://cdn.tryretool.com/js/react-dom.production.min.js"
crossorigin
></script>
<script src="https://unpkg.com/@material-ui/core@3.9.3/umd/material-ui.production.min.js"></script>
<div id="react"></div>
<script type="text/babel">
const MyCustomComponent = ({ triggerQuery, model, modelUpdate }) => {
return (
<input
id="upload"
type="file"
onChange={(event) => {
console.log(event.target.files[0]); modelUpdate({ file: event.target.files[0] });
}}
/>
);
};
const ConnectedComponent = Retool.connectReactComponent(MyCustomComponent);
ReactDOM.render(<ConnectedComponent />, document.getElementById("react"));
</script>
I dont want to use the already existed component, as i am getting base64 string