class Forest extends React.Component {
constructor(props) {
super(props)
this.plantRef = React.createRef()
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "debug.javascript.codelens.npmScripts": "never", | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // file: selected/dropped by user | |
| function displayImage(file) { | |
| const reader = new FileReader() | |
| reader.readAsDataURL(file) // reader.result will be `data:__` | |
| reader.onload = (e) => imageRef.current.src = reader.result | |
| console.log(reader.result) // returns `data:__` which is URL of files data | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upload(files) { | |
| const config = { | |
| onUploadProgress: function(progressEvent) { | |
| var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
| console.log(percentCompleted) | |
| } | |
| } | |
| let data = new FormData() | |
| data.append('file', files[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .Home { | |
| display: flex; | |
| min-height: 100vh; | |
| flex-direction: column; | |
| } | |
| .HomeContent { | |
| flex-grow: 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // src/middleware/errorHandler.js | |
| // Not found middleware | |
| // 404 | |
| const notFound = (req, res, next) => { | |
| const error = new Error(`Not Found - ${req.originalUrl}`); | |
| res.status(404); | |
| // pass error to the next middleware |