Я пытаюсь запустить тестирование снимков, но подхожу к этой ошибке:
фотография ошибки
Я считаю, что это потому, что у меня не установлен определенный пакет, но я не уверен, какой из них
.babelrc
{
"presets": ["react", "es2015"]
}
package.json
{
"name": "ovals",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/reactstrap": "^6.4.4",
"babel": "^6.23.0",
"babel-jest": "^23.6.0",
"bootstrap": "^4.2.1",
"browser-cookies": "^1.2.0",
"chromedriver": "^2.46.0",
"firebase": "^5.8.2",
"firebase-tools": "^6.7.0",
"jest": "^23.6.0",
"jimp": "^0.5.6",
"jquery": "^3.3.1",
"react": "^16.8.1",
"react-async-script-loader": "^0.3.0",
"react-bootstrap": "^0.32.4",
"react-dom": "^16.8.1",
"react-draggable": "^3.1.1",
"react-dropzone": "^8.0.4",
"react-icons": "^3.3.0",
"react-image-crop": "^6.0.12",
"react-paypal-button": "^2.0.3",
"react-popper": "^1.3.3",
"react-rnd": "^9.1.1",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.1.8",
"react-spinners": "^0.5.1",
"react-stripe-checkout": "^2.6.3",
"react-test-renderer": "^16.8.6",
"reactstrap": "^6.5.0",
"save": "^2.3.3",
"selenium-webdriver": "^4.0.0-alpha.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject",
"deploy": "firebase deploy"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"@babel/preset-react": "^7.0.0",
"babel-preset-react": "^6.24.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.12.1"
}
}
FileUploader.js
import React, { Component } from 'react';
import {FaUpload} from 'react-icons/fa';
import Dropzone from 'react-dropzone';
import ImagePreview from './ImagePreview.js';
const baseStyle = {
width: "100%",
height: 400,
borderWidth: 2,
borderColor: '#808080',
borderStyle: 'dashed',
backgroundColor: "#dcdcdc",
borderRadius: 5
};
const activeStyle = {
borderStyle: 'solid',
borderColor: '#6c6',
backgroundColor: '#eee'
};
const rejectStyle = {
borderStyle: 'solid',
borderColor: '#c66',
backgroundColor: '#eee'
};
class FileUploader extends Component{
constructor(props){
super(props);
this.removeImage = this.removeImage.bind(this);
let files = [];
if(props.fileList !== null && props.fileList !== undefined){
files = props.fileList;
}
this.state = {uploadedImages: files};
}
onDrop = (acceptedFiles, rejectedFiles) =>{
let arr = this.state.uploadedImages;
acceptedFiles.forEach(file => {
arr.push(file);
});
this.setState({uploadedImages: arr},function(){
this.props.onUpload(this.state.uploadedImages);
});
}
getPreviews(){
if(this.state.uploadedImages === null || this.state.uploadedImages ===
undefined){
return (
<div>
<ImagePreview width="100px" height="100px"/>
{/*<div style={emptyBox}/>*/}
</div>);
}else{
const previews = this.state.uploadedImages.map(function(img, index) {
return <ImagePreview img={URL.createObjectURL(img)} key={index}
width="100px" height="100px" onClick={() =>this.removeImage(index)}/>;
}.bind(this));
return (
<div>
{previews}
<ImagePreview width="100px" height="100px"/>
</div>
);
}
}
removeImage(index){
let arr = this.state.uploadedImages;
arr.splice(index,1);
this.setState({uploadedImages: arr});
}
render(){
return(
<div>
<Dropzone accept="image/*" onDrop={this.onDrop.bind(this)}>
{({ getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject, acceptedFiles, rejectedFiles }) => {
let styles = {...baseStyle}
styles = isDragActive ? {...styles, ...activeStyle} : styles
styles = isDragReject ? {...styles, ...rejectStyle} : styles
return (
<div {...getRootProps()} style={styles}>
<input {...getInputProps()} />
<div style={{margin: "auto", textAlign: "center", position: "relative", top: "30%"}}>
<FaUpload size="100"/><br/>
{!isDragReject &&<strong>Drag and drop or click here</strong>}
{isDragReject && <strong>You can only upload Images</strong>}
</div>
</div>
)
}}
</Dropzone>
<div style={{marginTop: "10px", border: "1px solid gray", padding: "5px"}}>
{this.getPreviews()}
</div>
</div>
);
}
}
export default FileUploader;
Если кто-нибудь знает, почему я получаю эту ошибку в Fileupload и как ее исправить, это было бы очень признательно