Using functional components instead of classes.

This commit is contained in:
Jayden Seric 2017-04-26 01:38:45 +10:00
parent 5f5008fca1
commit 0a1876b253
2 changed files with 8 additions and 14 deletions

View File

@ -1,11 +1,10 @@
import {Component} from 'react'
import {graphql, gql} from 'react-apollo'
import uploadsQuery from '../queries/uploads'
class MultipleUploader extends Component {
handleChange = ({target}) => {
const MultipleUploader = ({mutate}) => {
const handleChange = ({target}) => {
if (target.validity.valid) {
this.props.mutate({
mutate({
variables: {
files: target.files
},
@ -16,9 +15,7 @@ class MultipleUploader extends Component {
}
}
render () {
return <input type='file' accept={'image/jpeg,image/png'} multiple required onChange={this.handleChange} />
}
return <input type='file' accept={'image/jpeg,image/png'} multiple required onChange={handleChange} />
}
export default graphql(gql`

View File

@ -1,11 +1,10 @@
import {Component} from 'react'
import {graphql, gql} from 'react-apollo'
import uploadsQuery from '../queries/uploads'
class SingleUploader extends Component {
handleChange = ({target}) => {
const SingleUploader = ({mutate}) => {
const handleChange = ({target}) => {
if (target.validity.valid) {
this.props.mutate({
mutate({
variables: {
file: target.files[0]
},
@ -16,9 +15,7 @@ class SingleUploader extends Component {
}
}
render () {
return <input type='file' accept={'image/jpeg,image/png'} required onChange={this.handleChange} />
}
return <input type='file' accept={'image/jpeg,image/png'} required onChange={handleChange} />
}
export default graphql(gql`