DEV Community

ooo2003003v2
ooo2003003v2

Posted on

How do i use js file function in componentDidMount????

Hello there.
I have a problem. I have some functions in a js file and i wanna use it in my react js project. I referenced it in the head but when i call a of the function in the js file in componentDidMount it shows "'InitInput' is not defined no-undef"
Does anyone has a solution for my problem???
Thx

Input.jsx

class Input extends React.Component {
  constructor(props) {
    super(props);
    this.myRef = React.createRef();

  }
  componentDidMount() {($(this.myRef ))
  }
}

initInput.js

function InitInput(form){

alert()

}

Index.html

<html lang="en">
  <head>
 <script src="/jQuery/jquery-3.4.1.min.js" ></script>
    <script  src="/jQuery/initInput.js" ></script>
</head>
...
</html>

Top comments (0)