Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

pass text to button component react

// general component
<ButtonComponent text="General" />

 // button component
const ButtonComponent = (props) => {
  const handleClick = () => {
    console.log(props.text);
  };

  return (
    <button onClick={ handleClick }>{ props.text }</button>
  );
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pass #text #button #component #react
ADD COMMENT
Topic
Name
6+6 =