Apps Developer Guide (Old)
  • Introduction
  • Create your first app in 4 easy steps
  • Overview
    • How does it work ?
    • Documentation
    • Deskpro Apps Tool
  • SDK
    • The Application Manifest
      • Manifest Reference
    • Storing data
      • Storing ticket data
    • Accessing the Deskpro REST API
    • Accessing remote services
    • The Application Installer
    • Application Contexts
      • ContextDataObject Reference
    • Events
  • Guides
    • Create an Oauth2 integration
    • Using an API Key to read data
  • Application Context
    • Get the authenticated user
    • Access Custom Fields
    • Interacting with the Host UI Container
  • Application Container
    • How do I badge my app icon
  • HTTP
    • How do I use a remote web service
  • OAuth2
    • How do I customize OAuth2 requests
  • UI Patterns
    • How do I split my app into different screens
Powered by GitBook
On this page
  1. UI Patterns

How do I split my app into different screens

The most simple way is to use the light-weight router from the @deskpro/apps-sdk-react package. The router is an object with a method named to that allows you to change the current screen when called with a screen name:

  const { route } = this.props;
  route.to('my-screen')

You can also pass parameters to your screen:

  const { route } = this.props;
  route.to('my-screen', { myParam: 5 })

You will need to import the router components:

    import { Routes, Route } from '@deskpro/apps-sdk-react';

In your render method, wrap your screens in Route containers:

class App extends React.PureComponent {
  static propTypes = { 
     /**
     * Instance of the Deskpro App Sdk Client
     */
    dpapp: PropTypes.object,

    /**
     * Instance of sdk router.
     */
    route:   PropTypes.object,
  };

  /**
   * Show the authentication screen immediately after the component is mounted
   */
  componentDidMount() {
    const { route } = this.props;
    route.to('auth');
  }

  /**
   * @returns {*}
   */
  render() {
    return (
      <Routes>
        <Route location="auth" component={PageAuth} />
        <Route location="home" component={PageHome} />
        <Route defaultRoute>
          <p>Loading</p>
        </Route>
      </Routes>
    );
  }
}
PreviousHow do I customize OAuth2 requests

Last updated 6 years ago