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.
Properties:
Name Type Default Description
autoReset boolean true (static) Whether to automatically reset the navigation bar upon component display. (defaults to true)
navigationOptions NavigationBar (static) The navigation bar for this component. Defaults to a title of "Untitled" with no right Buttons.
Source:
Example
import { Component } from 'ern-navigation'
...
export default MainScreenComponent extends Component {
  static displayName = 'Main Screen'
  static autoReset = true;
  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) _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) _handleBlurEvent(payload)

Make a call to onBlur() (if available) whenever this view loses focus. If a subclassed instance contains the onBlur method, it will be called on blur events.
Parameters:
Name Type Description
payload string The stringified JSON payload for the event.
Source:

(private, static) _handleButtonEvent(payload)

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 OnNavEventEventListener. If a subclassed instance contains the onNavButtonPress method, that will be called on button press events, otherwise the class's static method will be called.
Parameters:
Name Type Description
payload string The stringified JSON payload for the event.
Source:

(private, static) _handleFocusEvent(payload)

Make a call to onFocus() (if available) whenever this view receives focus. If a subclassed instance contains the onFocus method, it will be called on focus events.
Parameters:
Name Type Description
payload string The stringified JSON payload for the event.
Source:

(private, static) _handleNavEvent(event)

Dispatch events for this component. This is called automatically whenever an event is fired by the OnNavEventEventListener.
Parameters:
Name Type Description
event NavigationEvent The navigation event.
Source:

(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) onBlur()

Handle blur events.
Source:

(abstract, static) onFocus()

Handle focus events.
Source:

(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