Error: The function window.intlTelInput is not recognized within the ReactJS framework

I am currently learning ReactJS and encountering an issue when using jQuery with React JS for intlTelInput. I have installed npm jQuery and imported all the necessary code. Additionally, I have included all the required CSS and jQuery links in my index.html file, but the code is still not functioning properly, resulting in the following error:

TypeError: window.intlTelInput is not a function

If anyone has any insights or solutions to this problem, I would greatly appreciate your assistance in resolving it.

Below is the snippet from my Index.html page where I have added all the CDN links:

<!DOCTYPE html>
<html lang="en">
  <head>
 

    <link rel="stylesheet" href="build/css/intlTelInput.css">
    <link href='https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/css/intlTelInput.min.css" />
    <!-- JS -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.min.js"></script> 
  
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
  
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- ---------------------------------------------------------------------------- -->


    <!--

      
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin development, run `npm start` or `yarn start`.
      For a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

This is the code for My Login Page:

import React from 'react'
import firebase from './firebase'
import "./App.css";
import { getDatabase, ref, child, get } from "firebase/database";
// import PhoneInput from 'react-phone-number-input'
import $ from 'jquery';
import intlTelInputUtils from 'jquery';


class Login extends React.Component {
  // <-------------------------------------------------------------------------------------->

  // jQuery functionality

  componentWillMount() {

    var phoneNumber = window.intlTelInput(document.querySelector("#phoneNumber"), {
      separateDialCode: true,
      preferredCountries: ["in"],
      hiddenInput: "full",
      utilsScript: "//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.js"
    });

    $("#getCode").click(function () {
      var full_num = phoneNumber.getNumber(intlTelInputUtils.numberFormat.E164);
      $("input[name='phoneNumber[full]'").val(full_num);

      localStorage.setItem("Phone_No", full_num)

    });
  }
  // // <--------------------------------------------------------------------------------------------------------->

  handleChange = (e) => {
    const { name, value } = e.target
    this.setState({
      [name]: value
    })
    this.setState({ phoneNumber: value }, () => {
      console.log(this.state.phoneNumber);
    });
  }
  configureCaptcha = () => {
    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
      'size': 'invisible',
      'callback': (response) => {

        // reCAPTCHA solved, allow signInWithPhoneNumber.

        this.onSignInSubmit();
        // console.log("Recaptca varified")
      },
      //  defaultCountry: "IN"
    }
    );
  }
  onSignInSubmit = (e) => {
    e.preventDefault()
    this.configureCaptcha()
    const phoneNumber = this.state.mobile
    const appVerifier = window.recaptchaVerifier;
    const dbRef = ref(getDatabase());
    get(child(dbRef, `Users/${phoneNumber}`)).then((snapshot) => {
      if (snapshot.exists()) {
        firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)

          .then((confirmationResult) => {

            // SMS sent. Prompt user to type the code from the message, then sign the
            // user in with confirmationResult.confirm(code).

            window.confirmationResult = confirmationResult;

            alert('An OTP has been sent to your registered mobile number')
            localStorage.setItem("Phone_No", phoneNumber)
            console.log(localStorage.getItem('Phone_No'));


          }).catch((error) => {

            console.error(error);
            alert("Oops! Some error occured. Please try again.")
          });
      }
      else {
        alert('Sorry, this mobile number is not registered with us. Please use your registered mobile number.');
      }

    })
  }
  onSubmitOTP = (e) => {
    e.preventDefault()
    const code = this.state.otp
    console.log(code)
    window.confirmationResult.confirm(code).then((result) => {
      // User signed in successfully.
      const Users = result.user;
      console.log(JSON.stringify(Users))
      this.props.history.push("/home");
    }).catch((error) => {
      alert("You have entered wrong code")
    });
  }

  render() {
    return (
      <div className="Main-header">
        <img src="./55k-logo.png" alt="Company Logo" style={{ height: "80px", width: "200px" }} />
        <br />
        <div>
          <h2>Login Form</h2>
          <p>Limtless Water. From Unlimited Air.</p>
          <form onSubmit={this.onSignInSubmit}>
            <div id="sign-in-button"></div>
            {/* <PhoneInput */}

            <label>Mobile Number</label> <br />
            {/* for="phoneNumber"  */}

            <input type="tel" id="phone" name="mobile" placeholder="Enter Your Number" required onChange={this.handleChange} />
            <div className="buttons">
              <button type="submit">Submit</button>
            </div>
          </form>
        </div>

        <div>
          <form onSubmit={this.onSubmitOTP}>
            <label >Code</label> <br />
            {/* for="code" */}

            <input type="number" name="otp" placeholder="Enter The 6 Digit OTP" required onChange={this.handleChange} />
            <div className="buttons">
              <button type="submit">Submit</button>
            </div>
          </form>
        </div>
      </div>
    )
  }
}
export default Login;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The cascading style sheet used by a lightbox

I constructed a lightbox using the following HTML code: <a id="show-panel" href="#">Show Panel</a> <div id="lightbox-panel"> <h2>Lightbox Panel</h2> <p>You can add any valid content here.</p> <p align="center" ...

Configuring Next-auth CredentialProvider and setting up redirection

I'm feeling a bit lost when it comes to understanding how the credentials provider and redirects work. The documentation mentions that the credentials provider doesn't support a callback and is specifically for OAuth providers, which I understand ...

Tips for creating space between two fluid divs

I'm currently facing an issue with the spacing between two child divs inside a parent div. The web page needs to be responsive for different screen widths, but the vertical space between the left and right divs is not behaving as expected. I am using ...

Changing font color of a selected item in Material-UI's textview

I have a select textview in my react app and I am wondering how to change the font color after selecting an item from this textview. <div> <TextField id="standard-select-currency" select fullWidth l ...

Switch out the name of multiple elements with mootools

Is there a Moo tool that can replace multiple element IDs? I currently have the following code: $$('myelement').each(function(el){ var get_all_labels = el.getElements('label'); var get_label_id = get_all_l ...

Validation check: Ensure that the value does not match any other field

Looking for a method to compare two fields and only validate them if they are not equal. This is the approach I've tried, but it's not working: yup .number() .required() .notOneOf( [FormField.houseHoldMembers as any], &ap ...

Ways to differentiate between an angular element and a jQuery element

In order to implement a feature where clicking outside of a dropdown hides it within a directive, I have the following code: $(document).click(function(e) { var selector = $(e.target).closest('.time-selector'); if (!selector. ...

What causes an error when attempting to add a new user to the database?

Currently, I am delving into the world of Mongodb. To kick things off, I initiated by executing npm install --save mongoose uuid within the confines of Terminal. The primary objective of my project revolves around storing user information in the database. ...

Perform an action when a key is held down and when it is released

I am looking to implement a function that needs to be called under certain conditions: It should be triggered every second while a key is being held down (for example, if the key is held down for five seconds, it should fire 5 times every second). If ...

The animation in CSS seems to be malfunctioning, but strangely enough, the exact same code works elsewhere

Recently, I encountered a strange issue with my project. An animation effect that was working perfectly fine suddenly stopped working when I opened the project. To troubleshoot, I downloaded the same project from my GitHub repository and found that the ani ...

How to get an empty object as a response in a NODE.JS request?

For some reason, I am attempting to send an object to my backend. Even though I can retrieve valuable information from my network's payload, my req.body consistently returns an empty object. View my issue ...

When defining a stripe in TypeScript using process.env.STRIPE_SECRET_KEY, an error of "string | undefined" is encountered

Every time I attempt to create a new stripe object, I encounter the error message "Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string& ...

The Bootstrap modal's submit button refuses to be clicked

I have a unique challenge on my hands - dynamically loading a table within my page where each row is editable in a Bootstrap modal and deletable using multiple checked checkboxes through ajax. Everything works smoothly at first, with the submit button insi ...

Issue with pushing inner list<object> in Knockout version 3.2.0

Currently, I am working with knockout.js on an ASP application. The issue I am facing involves a list of objects returned by the controller action to the view, where the objects in the list point to another list of objects. My struggle lies in adding new o ...

What are some solutions for resolving a background image that fails to load?

HTML: `<div class="food-imagesM imagecontainer"> <!--Page info decoration etc.--> </div>` CSS: `.food-imagesM.imagecontainer{ background-image: url("/Images/Caribbean-food-Menu.jpg"); background-repeat: no-repeat; backgroun ...

Is passport.js necessary if I am implementing Auth0 for authentication in my React application?

While passport.js is commonly used for server side authentication, if I am already utilizing Auth0 as the authentication service for my React application, do I still require passport.js? ...

Having trouble uploading an image to AWS using Angular and NodeJS?

I am currently working on a Node/Express application and I need to gather file information for uploading from an Angular/Ionic front end. To achieve this, I have created a separate Service in Angular that successfully retrieves the Image name. However, my ...

What is the best way to implement window.load in React Native?

I'm encountering an issue with a simple button on my page in Expo/React Native. When I try to navigate to a new page using window.open upon clicking the button, I receive an error message saying "undefined is not a function." Although I am utilizing ...

Ensure that grid rows occupy the least amount of space possible

I'm relatively new to grid layout and I've encountered a challenge that has me stuck. Here's what I have so far: codepen And this is the relevant part of the grid: grid-template: 'img date' 'img head' 'img s ...

What is the best way to extract a specific number from a table with Selenium, especially when the location remains consistent across all zip

Context: I am attempting to scrape data from a website with JavaScript using Selenium in Python. Goal: Extract a specific number from the table located at 159x26. I believed that this code would retrieve the number from row 159, column 26. Here is the c ...