custom-react-uploader
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

Custom React Uploader

Usage

One line of code worths thousands lines of explanations.
import React, { useEffect, useState } from 'react'
import Uploader, { convertUrlToUploadFileModel, UploadFileModel }  from 'custom-react-uploader'
import styles from './styles.module.scss'
const testUrl = `https://media.istockphoto.com/photos/desk-lamp-picture-id534400418?b=1&k=20&m=534400418&s=170667a&w=0&h=kWgxXtGPOGYwOg5WdvFebM_z3wAQBUG2wrTf24oBWTc=`
const Container: React.FC<any> = () => {
    const [images, setImages] = useState<UploadFileModel[]>([])
    useEffect(() => {
        convertUrlToUploadFileModel(testUrl, 'testName.jpg').then((res) => {
            setImages([res])
        })
    }, [])
    return <div className={styles.container}>
        <Uploader currentFiles={images} updateCurrentFiles={setImages} onError={(message, file) => {
            console.log('error ', message, file)
            }} multiple={true}
            onlyShowFileInfo={false}        
        />
    </div>
}

export default Container

Development

  1. Git clone the project https://github.com/duc168/custom-react-uploader.git
  2. Install lerna globally if you have not installed lerna yet, run yarn add lerna -g
  3. Run yarn to install the first packages
  4. yarn start to start developing
  5. yarn stop to stop developing
  6. yarn build to build a new version
Happy coding!

Package Sidebar

Install

npm i custom-react-uploader

Weekly Downloads

10

Version

0.0.15

License

MIT

Unpacked Size

105 kB

Total Files

10

Last publish

Collaborators

  • tranhducvnn