react-native-s3
react-native-s3 copied to clipboard
Add HOC for subscribe TransferUtility tasks
It looks like:
import React, { Component } from 'react'
import { subscribeTasks } from 'react-native-s3'
const type = 'all' // download, upload, all
const idAsKey = true
const mapTasksToProps = ({ uploadTasks, downloadTasks, methods }) => ({
uploadTasks,
downloadTasks,
upload: methods.upload,
download: methods.download,
refresh: methods.refresh,
})
const options = { withRef: true }
const Demo = ({ uploadTasks, downloadTasks }) => {
......
}
export default subscribeTasks(
type,
idAsKey,
mapTasksToProps,
options
)(Demo)
Or with decorators:
@subscribeTasks(
type,
idAsKey,
mapTasksToProps,
options
)
export default class Demo extends Component {
render() {
const { uploadTasks, downloadTasks } = this.props
return (
......
)
}
}