Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react hooks component re render when button press

const Button = () => {
  console.log("Button Rendered!");
  window.alert("Button Rendered");
  return <button onClick="">Press me</button>;
};

const TextInput = () => {
  const [textInput, setTextInput] = useState("Hallo");
  const onChangeInput = useCallback(
    (e) => {
      setTextInput(e.target.value);
    },
    [textInput]
  );
  return (
      <input
        type="text"
        onChange={onChangeInput}
        value={textInput}
      />
  );
}


export default function App() {
  return (
    <div>
      <TextInput/>
      <Button />
    </div>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: React Helmet with SSR integration 
Javascript :: adding function to objects js 
Javascript :: create react without jsx 
Javascript :: nested for loop js 
Javascript :: change the value in checkbox by button react 
Javascript :: how to compare two arrays javascript 
Javascript :: window.addEventListener("online"); 
Javascript :: sequelize left join attributes 
Javascript :: launch uikit modal from php 
Javascript :: jQuery hello world program 
Javascript :: javascript promise 
Javascript :: js instanceof 
Javascript :: javascript cartesian product 
Javascript :: anagram js 
Javascript :: how to make a preloader dissapear in html 
Javascript :: Error: A Route is only ever to be used as the child of element, never rendered directly. Please wrap your Route in a Route 
Javascript :: next js page 
Javascript :: bson to json converter 
Javascript :: javascript object get value by key in array 
Javascript :: Uncaught TypeError: $(...).jstree is not a function 
Javascript :: move element to the top of list javascript 
Javascript :: read image metadata javascript 
Javascript :: usecallback 
Javascript :: toastandroid react native 
Javascript :: canvas text gradient 
Javascript :: how to use radio buttons in react class-based components 
Javascript :: react toggle state 
Javascript :: biggest number javascript 
Javascript :: async wait for axios reactjs 
Javascript :: parseint javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =