Using functional components instead of classes.
This commit is contained in:
parent
5f5008fca1
commit
0a1876b253
@ -1,11 +1,10 @@
|
|||||||
import {Component} from 'react'
|
|
||||||
import {graphql, gql} from 'react-apollo'
|
import {graphql, gql} from 'react-apollo'
|
||||||
import uploadsQuery from '../queries/uploads'
|
import uploadsQuery from '../queries/uploads'
|
||||||
|
|
||||||
class MultipleUploader extends Component {
|
const MultipleUploader = ({mutate}) => {
|
||||||
handleChange = ({target}) => {
|
const handleChange = ({target}) => {
|
||||||
if (target.validity.valid) {
|
if (target.validity.valid) {
|
||||||
this.props.mutate({
|
mutate({
|
||||||
variables: {
|
variables: {
|
||||||
files: target.files
|
files: target.files
|
||||||
},
|
},
|
||||||
@ -16,9 +15,7 @@ class MultipleUploader extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
return <input type='file' accept={'image/jpeg,image/png'} multiple required onChange={handleChange} />
|
||||||
return <input type='file' accept={'image/jpeg,image/png'} multiple required onChange={this.handleChange} />
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default graphql(gql`
|
export default graphql(gql`
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import {Component} from 'react'
|
|
||||||
import {graphql, gql} from 'react-apollo'
|
import {graphql, gql} from 'react-apollo'
|
||||||
import uploadsQuery from '../queries/uploads'
|
import uploadsQuery from '../queries/uploads'
|
||||||
|
|
||||||
class SingleUploader extends Component {
|
const SingleUploader = ({mutate}) => {
|
||||||
handleChange = ({target}) => {
|
const handleChange = ({target}) => {
|
||||||
if (target.validity.valid) {
|
if (target.validity.valid) {
|
||||||
this.props.mutate({
|
mutate({
|
||||||
variables: {
|
variables: {
|
||||||
file: target.files[0]
|
file: target.files[0]
|
||||||
},
|
},
|
||||||
@ -16,9 +15,7 @@ class SingleUploader extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
return <input type='file' accept={'image/jpeg,image/png'} required onChange={handleChange} />
|
||||||
return <input type='file' accept={'image/jpeg,image/png'} required onChange={this.handleChange} />
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default graphql(gql`
|
export default graphql(gql`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user