Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react

// I would suggest using function components react hooks 
// if you use react version > 16.8. React function components have
// various advantages over React class. Check them out here:
// https://reactjs.org/docs/hooks-intro.html

import React, { useState } from 'react';

const Example = (props) => {
  // Declare a new state variable, which we'll call "count"
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>Hello {props.name}. You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}
Source by reactjs.org #
 
PREVIOUS NEXT
Tagged: #react
ADD COMMENT
Topic
Name
1+1 =