GithubHelp home page GithubHelp logo

Comments (9)

rainst avatar rainst commented on June 1, 2024 4

I found a simpler solution, require jquery like this:

import OwlCarousel from 'react-owl-carousel';
const $ = require('jquery');

and you can use $ wherever you want in your component (tested in my code)

from react-owl-carousel.

rainst avatar rainst commented on June 1, 2024 1

Ok, i see your problem now...

I found this answer that might help you it's very similar to what you were doing, try to see if it works for you:
https://stackoverflow.com/questions/44088235/how-to-use-jquery-dependant-plugins-in-create-react-app

from react-owl-carousel.

usamamashkoor avatar usamamashkoor commented on June 1, 2024 1

Thanks, @rainst for your great solutions kindly let me try them.

Thanks again :)

from react-owl-carousel.

danranshizhi avatar danranshizhi commented on June 1, 2024

是不是这个插件只能在webpack中使用?因为之前在webpack中使用是没问题的

from react-owl-carousel.

GeKorm avatar GeKorm commented on June 1, 2024

The version of jquery is 3.3.1, the version of react is 16.3, which meets the requirements, but it is still reported fn undefined. How to deal with this situation?

Same problem here

from react-owl-carousel.

rainst avatar rainst commented on June 1, 2024

fn undefined usually means jquery is not defined.. how are you including jquery in your project??

from react-owl-carousel.

usamamashkoor avatar usamamashkoor commented on June 1, 2024

@rainst I am using the jquery like this
import OwlCarousel from 'react-owl-carousel';
import $ from 'jquery';

window.jQuery = $;
window.$ = $;
global.jQuery = $;

but i am still facing the issue

TypeError: Cannot read property 'fn' of undefined react

Can you please help me on this, please...?

jquery version is 3.4.0

from react-owl-carousel.

rainst avatar rainst commented on June 1, 2024

Hi @usamamashkoor,i think you are not doing it right..

I guess that when you are doing this:

window.jQuery = $;
window.$ = $;
global.jQuery = $;

you are trying to expose jquery in the react component, but that's not the proper way of doing it, try to see if this solution is working:

https://stackoverflow.com/questions/45693800/how-to-use-a-jquery-dependent-node-module-in-react-js

from react-owl-carousel.

usamamashkoor avatar usamamashkoor commented on June 1, 2024

Thanks, @rainst but can you please let me know how can I add a plugin in web pack in create react app...?

from react-owl-carousel.

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.