Skip to content

Instantly share code, notes, and snippets.

@creationix
Created August 3, 2017 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/6211c57b23bfd5475fbbc2e5b973907c to your computer and use it in GitHub Desktop.
Save creationix/6211c57b23bfd5475fbbc2e5b973907c to your computer and use it in GitHub Desktop.
React Native Test
import React, { Component } from 'react'
import { View } from 'react-native'
export default class FlexDimensionsBasics extends Component {
constructor (props) {
super(props)
this.state = {time: Date.now()}
// Toggle the state every second
setInterval(() => {
this.setState(previousState => {
return {time: Date.now()}
})
}, 16)
}
render () {
return (
<View style={{flex: 1}}>
<View style={{flex: Math.sin(this.state.time / 1100) + 2, backgroundColor: 'red'}} />
<View style={{flex: Math.sin(this.state.time / 990) + 2, backgroundColor: 'orange'}} />
<View style={{flex: Math.sin(this.state.time / 880) + 2, backgroundColor: 'yellow'}} />
<View style={{flex: Math.sin(this.state.time / 770) + 2, backgroundColor: 'green'}} />
<View style={{flex: Math.sin(this.state.time / 660) + 2, backgroundColor: 'blue'}} />
<View style={{flex: Math.sin(this.state.time / 550) + 2, backgroundColor: 'violet'}} />
</View>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment