Skip to content

Instantly share code, notes, and snippets.

@teyfix
Created June 23, 2021 05:32
Show Gist options
  • Save teyfix/2eb300ad5eb4fbb9896ab3322b233599 to your computer and use it in GitHub Desktop.
Save teyfix/2eb300ad5eb4fbb9896ab3322b233599 to your computer and use it in GitHub Desktop.
react - using props
const HelloWorld = () => {
const [show, setShow] = useState(false);
return (
<section>
<h1>Merhaba dünya!</h1>
<GoodMorning show={show} />
<button onClick={() => setShow(!show)}>Merhaba!</button>
</section>
);
};
const GoodMorning = (props) => {
if (props.show) {
return <p>Günaydın</p>;
}
return null;
};
ReactDOM.render(HelloWorld, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment