React Ape

React Ape

  • Docs
  • Contributing
  • Blog
  • GitHub
  • React

›Guides

The Basics

  • Getting Started
  • Learning the Basics
  • Height and Width

Guides

  • Components and APIs
  • Navigation on Apps
  • Custom Components

Contributing

  • How to Contribute

Components

  • Image
  • Text
  • View

APIs

  • Dimensions
  • Platform
  • StyleSheet
  • Navigation

Props

  • Image Style Props
  • Text Style Props
  • View Style Props
Edit

Navigation on Apps

Creating navigation with React Ape

React-Ape exports two functions: withFocusable and withNavigation. A declarative navigation system based on HOC's for focus and navigation control.

Those HOC's can be imported by

import { Navigation } from 'react-ape'
/* 
  You can also import using: 
  import { withFocusable, withNavigation } from 'react-ape/modules/Navigation'
*/

const { withFocusable, withNavigation } = Navigation;

For more information about the API, click here to see the navigation API documentation.

Usage overview:

import React from 'react'
import { Text, View, render } from 'react-ape'
import { withFocusable, withNavigation } from 'react-ape/modules/Navigation'

const Item = ({focused, setFocus, focusPath}) => {
  focused = (focused) ? 'focused' : 'unfocused'
  return (
    <View onClick={() => { setFocus() }}>
      <Text>It's {focused} Item</Text>
    </View>
  )
}

const Button = ({setFocus}) => {
  return (
    <View onClick={() => { setFocus('item-1') }}>
      <Text>Back To First Item!</Text>
    </View>
  )
}


const FocusableItem = withFocusable(Item)
const FocusableButton = withFocusable(Button)

function App({currentFocusPath}) {
  return (
    <View>
      <Text>Current FocusPath: '{currentFocusPath}'</Text>,
      <FocusableItem focusPath='item-1'/>
      <FocusableItem focusPath='item-2'/>
      <FocusableButton
        focusPath='button'
        onEnterPress={() => console.log('Pressed enter on Button!')}/>
    </View>
  )
}

const NavigableApp = withNavigation(App)

render(<NavigableApp/>, document.querySelector('#canvas-id'))
← Components and APIsCustom Components →
  • Creating navigation with React Ape
    • Usage overview:
Docs
Getting StartedGuidesAPI Reference
Community
Who is Using React-Ape?Twitter
More
BlogGitHubStar React Ape on GitHub
Copyright © 2022 Raphael Amorim