This repository was archived by the owner on Oct 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Menu Actions
_N_I_X_O_N_ edited this page Oct 30, 2019
·
1 revision
This Wiki show you how to implement a simple menu.
import React, { Component } from 'react'
import Turbolinks from 'react-native-turbolinks'
const baseUrl = 'http://MYIP:9292'
export default class App extends Component {
componentDidMount() {
Turbolinks.addEventListener('turbolinksVisit', this.handleVisit)
Turbolinks.addEventListener('turbolinksError', this.handleError)
Turbolinks.addEventListener('turbolinksActionPress', this.handleActionPress)
Turbolinks.startSingleScreenApp({url: baseUrl, actions: [{id: 0, title: 'Page One'}, {id: 1, title: 'Page Two'}]})
}
handleVisit = (data) => {
Turbolinks.visit({url: data.url, action: data.action})
}
handleError = (data) => {
alert(data.description)
}
handleActionPress = (actionId) => {
switch (actionId) {
case 0:
Turbolinks.visit({url: baseUrl + '/one'})
break
case 1:
Turbolinks.visit({url: baseUrl + '/two'})
break
}
}
render() {
return null
}
}