TypeError: Cannot set property '$' of undefined
TypeError: Cannot set property '$' of undefined

hi,i want use datatables in react. use
const $ = require('jquery');
dt(window, $);
but have a error
TypeError: Cannot set property '$' of undefined
i need help who can help me
thanks very much
This discussion has been closed.
Answers
Hi @Rookieeeee ,
Try
Cheers,
Colin
See https://datatables.net/manual/installation#NPM
hi @colin i use
var $ = require( 'jquery' );
var dt = require( 'datatables.net' )( window, $ );
but alwyas have the questions
Hi @Rookieeeee ,
Could you link to your page, or paste your code here, please.
Cheers,
Colin
Hi @colin


thanks your help
i use
var $ = require( 'jquery' );
var dt = require( 'datatables.net' )( window, $ );
always have this question
i create project use create-react-app
Can you create an example repo showing the issue for me so I can have a little play around with it?
Thanks,
Allan
HI @allan my pro demo :https://github.com/xuningyang/datatables.git
you can use: git clone https://github.com/xuningyang/datatables.git
and npm install and npm start
Thanks
hi @allan @colin
you can use demo to show problem;
Thanks
Thanks! I removed your two
require
lines for DataTables and jQuery and replaced with the following at the top of the file:Checking that DataTables was loaded I used
.
console.log( dt.version );
which did the job nicely (the console showed 1.10.19). Yo should be able to use jQuery and DataTables from thereAllan