Tiny-slider: We should be able to import tiny-slider and avoid errors when window and document are undefined.

Created on 17 Sep 2018  路  3Comments  路  Source: ganlanyuan/tiny-slider

__Issue description__:
I am rendering a react component on the server using ReactJS.NET but because window and document don't exist on the server, tinyslider runs into issues when trying to work. I propose that we build in logic to the slider to avoid errors when window and document are not defined. This will not affect functionality, it will just allow error-free rendering.

__Demo link/slider setting__: n/a

_Tiny-slider version_: n/a
_Browser name && version_: n/a
_OS name && version_: n/a

Most helpful comment

I think that a big warning should be displayed in the README since this won't work with server-side rendered apps.

Yes this is true, my solution was to wrap the calls to tns in something like this

if(process.env.NODE_ENV !== 'server') { 
  tns({...});
}

All 3 comments

After investigation I don't think this is possible because of dependencies also needing window and document.

I think that a big warning should be displayed in the README since this won't work with server-side rendered apps.

I think that a big warning should be displayed in the README since this won't work with server-side rendered apps.

Yes this is true, my solution was to wrap the calls to tns in something like this

if(process.env.NODE_ENV !== 'server') { 
  tns({...});
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

b3nhartl3y picture b3nhartl3y  路  3Comments

youradds picture youradds  路  3Comments

CristianEstiber picture CristianEstiber  路  3Comments

notrealdev picture notrealdev  路  5Comments

vinogradov picture vinogradov  路  5Comments