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

(private, static) _getLocalizedNavigationBar(jsonPayload) → {NavigationBar}

Get a localized version of the navigation bar for this route.
Parameters:
Name Type Description
jsonPayload Object The JSON payload for the current route.
Source:
Returns:
A NavigationBar object with the IDs of buttons updated to pertain to the current route.
Type
NavigationBar

(private, static) _getNavigationBar(jsonPayload) → {NavigationBar}

Get the navigation bar for the given route.
Parameters:
Name Type Description
jsonPayload Object The JSON payload for the current route.
Source:
Returns:
A NavigationBar object for the given route.
Type
NavigationBar

(private, static) _handleNavButtonPress(buttonId)

Make a call to onNavButtonPress(buttonId) (if available) whenever a button is pressed in the navigation bar. This is called automatically whenever an event is fired by the OnNavButtonClickEventListener. If a subclassed instance contains the onNavButtonPress method, that will be called, otherwise the class's static method will be called.
Parameters:
Name Type Description
buttonId string The ID of the Button that was pressed.
Source:

(private, static) _localizeNavigationBar(routeName, navigationBar) → {NavigationBar}

Get a localized version of the navigation bar for the given route.
Parameters:
Name Type Description
routeName string The name of the current route.
navigationBar NavigationBar The NavigationBar object to localize.
Source:
Returns:
A NavigationBar object with the IDs of buttons updated to pertain to the given route.
Type
NavigationBar

(private, static) _shouldDispatchButtonPressEvent(buttonId)

Determine whether to dispatch an onNavButtonPress event for a given buttonId.
Parameters:
Name Type Description
buttonId string The ID of the Button.
Source:

(private, static) _unlocalizeButtonId(buttonId)

Get an unlocalized version of a button.
Parameters:
Name Type Description
buttonId string The ID of the Button to unlocalize.
Source:
Example
// returns 'ButtonIdentifier'
NavigationBar._unlocalizeButtonId('RegisteredRoute.ButtonIdenfifier')

(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