React-sortable-tree: Window is not defined react-sortable-tree/dist/main.js:1080

Created on 12 Sep 2017  路  2Comments  路  Source: frontend-collective/react-sortable-tree

Hello I have this problem, 5 days ago The library worked fine, but today I'm trying to run 'npm run dev' in my project, and gives me this error.. (I have reinstalled through npm and it doesn't work)

image

Most helpful comment

After some time, this was solved replacing:

import { SortableTree } from 'react-sortable-tree'
with

const isBrowser = typeof window !== 'undefined'
const SortableTree = isBrowser ? require('react-sortable-tree').default : undefined

Is strange, but it solved the problem

All 2 comments

After some time, this was solved replacing:

import { SortableTree } from 'react-sortable-tree'
with

const isBrowser = typeof window !== 'undefined'
const SortableTree = isBrowser ? require('react-sortable-tree').default : undefined

Is strange, but it solved the problem

Hi, I've got the same issue. If this component is supposed to be used with SSR I suppose this is a bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jorgecuesta picture jorgecuesta  路  4Comments

brendanmoore picture brendanmoore  路  5Comments

2503shubham picture 2503shubham  路  3Comments

mcolburn picture mcolburn  路  4Comments

NickEmpetvee picture NickEmpetvee  路  3Comments