Code Monkey home page Code Monkey logo

Comments (4)

hollowaysmith avatar hollowaysmith commented on May 22, 2024 2

I ended up copying the build file and adding some safety checks to usage of window. There were only about 10 changes needed to make it work. Copy this file to your project and import it instead of the react-awesome-slider NPM distribution.

https://gist.github.com/hollowaysmith/c359b0530420ac955108e8579bddd537

It works for me in Gatsby with this change.

@rcaferati SSR just needs safety checks around window before using it. Ie,

before:

window.requestAnimationFrame(() => {  (stuff) }

after:

window && window.requestAnimationFrame(() => {  (stuff) }

I'd prefer to use your distribution if this was fixed 😄

from react-awesome-slider.

Zeroxys avatar Zeroxys commented on May 22, 2024

any answer about how solve this ?

from react-awesome-slider.

csprance avatar csprance commented on May 22, 2024

If you are using something like nextjs you can do

import dynamic from 'next/dynamic';
import * as React from 'react';

/*
This requires access to the window so we need to dynamically import it with no SSR
 */
const AwesomeSlider = dynamic(() => import('react-awesome-slider'), {
  ssr: false
});

export default AwesomeSlider;

and then import the css and use it like normal.

from react-awesome-slider.

rcaferati avatar rcaferati commented on May 22, 2024

@stephenbaldwin thanks for raising it. Fixed on v1.1.0. If you guys find any issues with it, just comment here.

from react-awesome-slider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.