Nextjs issue
itranga opened this issue · 0 comments
I try to used it in nextjs project .
Issue
✔ success server compiled in 1s 805ms
Uncaught Exception: ReferenceError: window is not defined
at Object. (/home/ranga/code/book/book/node_modules/fine-uploader/fine-uploader/fine-uploader.core.js:5774:4)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/home/ranga/code/book/book/node_modules/fine-uploader/lib/core/index.js:3:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
My code
#/// Uploading.js
const { Promise } = global
export const asyncLoad = () => {
return new Promise(resolve => {
require.ensure([], () => {
resolve({
FineUploaderTraditional: require('react-fine-uploader').default,
Gallery: require('react-fine-uploader/components/gallery').default
})
})
})
}
#/// Fine-Uploader.js
import React from 'react'
import { asyncLoad } from './Uploading' // Lazy Loaded Image Loader
export default React.createClass ({
getInitialState: function() {
return {}
},
componentWillMount: function () {
asyncLoad().then(({ FineUploaderTraditional, Gallery }) => {
const uploader = new FineUploaderTraditional({
options: {
autoUpload: true,
chunking: {
enabled: true
},
request: {
endpoint: '/api/v0/upload'
},
deleteFile: {
enabled: true,
endpoint: '/api/v0/upload'
},
callbacks: {
onComplete: (id, name, response) => {
console.log(id, name, response)
}
}
}
})
this.setState({ uploader, Gallery })
})
},
render: function () {
const { Gallery, uploader } = this.state
return (
{!('Gallery' in this.state) &&
{'Gallery' in this.state && }
)
}
})