1

How to use jquery & custom js like : $("#header").sticky({ topSpacing: 0, zIndex: "50" }); in reactjs

Below config is not working for me.

I am using this repo. https://github.com/ctrlplusb/react-universally

import $ from 'jquery';
require('bootstrap3');
require('../../assets/lib/stickyjs/sticky')
if (typeof window === 'undefined') {
  global.window = {}
  global.document = {}
}

SERVER: Error in server execution, check the console for more info.

ReferenceError: window is not defined

SHR
  • 7,940
  • 9
  • 38
  • 57
  • Possible duplicate of [How to use JQuery on ReactJS](https://stackoverflow.com/questions/38518278/how-to-use-jquery-on-reactjs) – Metalik Jul 04 '18 at 09:57
  • @AndrewL Okay but getting below error. how to solve it. ReferenceError: window is not defined – Hirani Vipul Jul 04 '18 at 10:07

1 Answers1

0

This should work.

let w = window;
let $ = w.$;
RIYAJ KHAN
  • 15,032
  • 5
  • 31
  • 53