Class: Component

Component()

new Component()

NOTE:
If overriding componentWillUnmount or componentWillUpdate, you must call the appropriate super method - super.componentWillUnmount() or super.componentWillUpdate(nextProps, nextState), respectively.
Source:
Example
import { Component } from 'ern-navigation'
...
export default MainScreenComponent extends Component {
  static displayName = 'Main Screen'
  static navigationOptions = {
    title: 'My Application',
    buttons: [{
      icon: Image.resolveAssetSource(exitIcon).uri,
      id: 'exit',
      location: 'right',
      accessibilityLabel: 'Exit this app'
    }]
  }
 onNavButtonPress (buttonId) {
   switch (buttonId) {
     case 'exit':
       this.finish()
       break
     default:
       console.warn(`Screen '${MainScreenComponent.getRegisteredRoute()}' received unmapped button id '${buttonId}'`)
       break
   }
 }
  ...
}

Extends

  • React.Component

Methods

(static) getAppNavigator() → {AppNavigator}

Get the AppNavigator for this component.
Source:
Returns:
The AppNavigator for this component.
Type
AppNavigator

(abstract, static) getDynamicTitle(jsonPayload)

Calculate the title for the current route based on the JSON payload. Must be overriden in subclasses.
Parameters:
Name Type Description
jsonPayload Object The JSON payload for the current route.
Source:

(static) getRegisteredRoute() → {string}

Get the registered route for this component.
Source:
Returns:
A string containing the registered route for this component.
Type
string

(abstract, static) onNavButtonPress(buttonId)

Handle button press events. Must be overriden in subclasses.
Parameters:
Name Type Description
buttonId string The ID of the button which was pressed.
Source:

(static) setAppNavigator(appNavigator)

Set the AppNavigator for this component.
Parameters:
Name Type Description
appNavigator AppNavigator The AppNavigator for this component.
Source:

(static) setRegisteredRoute(route)

Set the registered route for this component.
Parameters:
Name Type Description
route string The registered route for this component.
Source:

(async) back() → {Promise}

Go back one screen.
Source:
Returns:
A Promise which will resolve or reject upon attempting to go back one screen.
Type
Promise

(async) backTo(screenName) → {Promise}

Go back to a specified screen.
Parameters:
Name Type Description
screenName string The name of the screen to navigate to; these names should be defined in the initial AppNavigator setup.
Source:
Returns:
A Promise which will resolve or reject upon attempting to go back to the specified screen.
Type
Promise

(async) finish(payloadopt) → {Promise}

Finish this flow.
Parameters:
Name Type Attributes Description
payload Object <optional>
(optional) The JSON payload to send to the native activity or view controller that launched the flow.
Source:
Returns:
A Promise which will resolve or reject upon attempting to finish the current flow.
Type
Promise
Navigate to a given route.
Parameters:
Name Type Description
route Object The route object that details where to navigate next.
Source:
Returns:
A Promise which will resolve or reject upon attempting to navigate to the given route.
Type
Promise
Navigate to an internal screen.
Parameters:
Name Type Attributes Description
screenName string The name of the screen to navigate to; these names should be defined in the initial AppNavigator setup.
jsonPayload Object <optional>
(optional) The JSON payload with props to send to the new screen.
Source:
Returns:
A Promise which will resolve or reject upon attempting to navigate to the new screen.
Type
Promise

(async) resetNavigationBar() → {Promise}

Reset the navigation bar for the current screen to its defaults.
Source:
Returns:
A Promise which will resolve or reject upon attempting to reset the navigation bar.
Type
Promise

(async) updateNavigationBar(navigationBar) → {Promise}

Update the navigation bar for the current screen.
Parameters:
Name Type Description
navigationBar NavigationBar The NavigationBar object.
Source:
Returns:
A Promise which will resolve or reject upon attempting to update the navigation bar.
Type
Promise