Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { AppRegistry, Text, View } from 'react-native';
  3.  
  4. class Blink extends Component {
  5.  
  6. componentDidMount(){
  7. // Toggle the state every second
  8. setInterval(() => (
  9. this.setState(previousState => (
  10. { isShowingText: !previousState.isShowingText }
  11. ))
  12. ), 1000);
  13. }
  14.  
  15. //state object
  16. state = { isShowingText: true };
  17.  
  18. render() {
  19. if (!this.state.isShowingText) {
  20. return null;
  21. }
  22.  
  23. return (
  24. <Text>{this.props.text}</Text>
  25. );
  26. }
  27. }
  28.  
  29. export default class BlinkApp extends Component {
  30. render() {
  31. return (
  32. <View>
  33. <Blink text='I love to blink' />
  34. <Blink text='Yes blinking is so great' />
  35. <Blink text='Why did they ever take this out of HTML' />
  36. <Blink text='Look at me look at me look at me' />
  37. </View>
  38. );
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement