I’m fairly new to Materialize, and I thought I could use it to develop a project with ReactJS. Unfortunately, looks like jQuery is not really liked by React. I tried to write some dummy code, which is just supposed to show a date input provided by Materialize:
import React, { Component } from 'react';
import $ from 'jquery';
import 'materialize-css';
class App extends Component {
componentDidMount() {
$(document).ready(function() {
$('.datepicker').datepicker({
disableWeekends: true
});
})
}
render() {
return (
<div className="App">
<div className="input-field">
<input type="text" id="date" className="datepicker" />
<label for="date">Choose a date you need me for...</label>
</div>
</div>
);
}
}
export default App;
This last snippet of code doesn’t work, I get
TypeError: jquery__WEBPACK_IMPORTED_MODULE_1___default(...)(...).datepicker is not a function
I’m not a huge fan of jQuery, so I can drop it if I need to, but is there a way I can still use its methods (which I need access to for Materialize)?