I'm fairly new to react and next.js, I have a custom script I want to integrate in my next.js project. I added the link in the <head> tag
<script src="https://www.mews.li/distributor/distributor.min.js"></script>
This is the example that was give on the website :
Mews.Distributor({
configurationIds: ['myId'],
}, function (distributor) {
$('.booking-button').click(function () {
distributor.open();
});
});
when I used this in a normal html page that has jquery it works fine. I can't understand how do I reach the function (distributor) part from my react component.
My components is this:
export default class roomDetails2 extends React.Component<{}, {}>{
constructor(props) {
super(props);
this.state = {
someVar: '',
};
}
openMews(){
// somehow to access the script function here
}
render() {
return (
<>
<Head>
<script src="https://www.mews.li/distributor/distributor.min.js"></script>
</Head>
<div className="main_body">
<button onClick={() => this.openMews()}>click here to open</button>
</div>
</>
);
}
}