Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Nextjs issue #224

Open
itranga opened this issue Nov 9, 2018 · 0 comments
Open

Nextjs issue #224

itranga opened this issue Nov 9, 2018 · 0 comments

Comments

@itranga
Copy link

itranga commented Nov 9, 2018

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) &&
Loading Image Loader
}
{'Gallery' in this.state && }

)
}
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant