Created
February 3, 2019 07:21
-
-
Save galihlprakoso/46a2e881a08ee7383f9df8cf9c5d2b1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pahlawan extends React.Component { | |
state = { tampil:true };//Menginisialisasi state tampil=true sebagai nilai awal | |
componentDidMount(){ | |
setInterval(() => ( //Berfungsi untuk memanggil fungsi secara berulang-ulang | |
this.setState({ tampil: !this.state.tampil })//Mengubah state menjadi nilai inversnya | |
), 1000);//Delay dalam miliseconds 1000ms = 1 detik. | |
} | |
render(){ | |
if(!this.state.tampil){//Jika tampil==false maka akan mengembalikan nilai 'null' | |
return null; | |
} | |
return ( | |
<View> | |
{/* Menampilkan props 'nama' yang dikirimkan oleh Parentnya. */} | |
<Text>{this.props.nama}</Text> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment