1.0.6 • Published 1 year ago
image-uploader-react v1.0.6
How to configure
import { useState } from 'react';
import { ImageUploader } from 'image-uploader-react';
function App() {
const [file,setFile]=useState(null)
const handleSubmit=(e)=>{
e.preventDefault()
console.log(file,'file')
}
const getValue=(value)=>{
setFile(value)
}
const propsCollection = {
value:getValue,
updateColor: "green",
deleteColor: "Red",
mode:2
}
return (
<div >
<div className='m-4'>
<form onSubmit={(e)=>handleSubmit(e)} >
<ImageUploader {...propsCollection}/>
<button type='submit' className='btn btn-info mt-1 '>Submit</button>
</form>
</div>
</div>
);
}
export default App;
Props :
- value : it must be a function that accepts a value and set it to the state. This state will give us the selected file. This field is mandatory.
- updateColor : used to configure the color of update button (default is green). if nothing is given , green is taken as default.
- deleteColor : used to configure the color of delete button (default is red). if nothing is given, red is taken as default.
mode : there are 2 modes of ui. You can give either 1 or 2. if nothing is given 2 is taken as default
Note: all props need to be sent as a single object
Eg: const propsCollection={ value:getValue, updateColor:'red', deleteColor:'blue', mode:1 }