React Native Flashcards
What is React Native
- JS framework for mobile app development that renders to native iOS and Android code
- built on top of React JS
- uses React platform to create a bridge between JS sytax and host platform
- React components return markup, React uses the markup on DOM, React Native translates the markup to the host platform
core components
Text Image View TextInput ListView
virtual DOM
- React creates an in-memory data structure cache, computers the resulting differences and then updates the browser’s displayed DOM efficiently.
- React libraries only render subcomponents that actually change.
Flexbox
- works the same way as it does in CSS on the web
- provides a fixed layout on different screen sizes
FlatList
component that displays the content in similarly structured data as a scrollable list
geolocation
use the Location Services :
- React-native-geolocation-service
- React-native-location
props
- short for properties
- immutable
- components receive props from their parent
- enables code reuse
// Parent export default class ScreenOne extends React.Component { render () { return (
) } }
// Child component export default class Heading extends React.Component { render () { return (
{this.props.message}
) } } Heading.propTypes = { message: PropTypes.string } Heading.defaultProps = { message: 'Heading One' }
state
- internal to a component
- mutable
- handles data that is changeable
- use setState to update state objects
class Form extends React.Component {
constructor (props) { super(props) this.state = { input: '' } }
handleChangeInput = (text) => {
this.setState({ input: text })
}
render () {
const { input } = this.state
return ( ) } }
StyleSheet.create
- ensures that values are immutable and opaque
- only created once
Steps to create and start a React Native app
- npm install -g create-react-native-app
- create-react-native-app AwesomeProject
- cd AwesomeProject
- npm start
XHR Module
used for implementation of XMLHttpRequest to post data on the server
function used to pass values between screens
this.props.navigation.navigate(‘RouteName, { /* params go here */ })
JavaScriptCore
- open-source Web browser engine which runs in Webkit.
- helps developers create own browser
WebView
- component that is implemented to load a web page or web content
- bridge that connects web platforms with React Native
Gesture Responder System
manages lifecycle of gestures in the app