Category : global

Hi I want to create a global variable in react but I would like to avoid it, so I created a component and want to store string data in it such as below: export default function settings() { const [stringData, setStringData] = useState(""); I want this state to concactnate input string. For example setStringData("I am ..

Read more

I need to declare a variable inside a function and make it global. I also need to do this with an if statement but I can’t declare it outside of the function because I’m calling it with addeventlistner() var map = document.getElementById(‘Map’); map.addEventListener(‘click’, find_number, false); function find_number(e) { //here is where I would like declare ..

Read more

So I had this strange occurrence with Browserify where even if my functions were made to function in the global scope, the console still shows: Uncaught ReferenceError: testing is not defined at HTMLButtonElement.onclick (signUp.html:86) As you can see, I made a testing script for this bellow: Pre-Browserify Build Window.testing = function() { console.log(‘this executed’); } ..

Read more

Consider the code below: Ignore all the axios request: Login.js const login = async () => { let newLogin = { email, password, }; await axios .post("http://localhost:5000/login", newLogin) .then((response) => { if (response.data === 404) { setUserError("User not found. Please Sign Up"); } else if (response.data === 403) { setPasswordError("Incorrect Password"); } else { dispatch({type:’LOG_IN’,payload:{LoggedIn:true ..

Read more