Skip to content

Instantly share code, notes, and snippets.

@dcortesnet
Created February 27, 2023 01:57
Show Gist options
  • Select an option

  • Save dcortesnet/34651aa0e8db5663d6df71fc6aa21084 to your computer and use it in GitHub Desktop.

Select an option

Save dcortesnet/34651aa0e8db5663d6df71fc6aa21084 to your computer and use it in GitHub Desktop.
Reactjs smart component y dump component
// Smart Component
import React, { useState } from 'react';
import DumpComponent from './DumpComponent';
const SmartComponent = () => {
const [name, setName] = useState('');
const handleInputChange = (e) => {
setName(e.target.value);
};
const handleButtonClick = () => {
alert(`Hello, ${name}!`);
};
return (
<DumpComponent
name={name}
onInputChange={handleInputChange}
onButtonClick={handleButtonClick}
/>
);
};
export default SmartComponent;
// Dump Component
import React from 'react';
const DumpComponent = ({ name, onInputChange, onButtonClick }) => {
return (
<div>
<input type="text" value={name} onChange={onInputChange} />
<button onClick={onButtonClick}>Say Hello</button>
</div>
);
};
export default DumpComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment