question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding the ability to use TopNavigation component for rendering the popover-based components

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request

Issue description

Current behavior: At the moment there is no possibility to use the TopNavigationAction component for showing Popover-based components since the TopNavigation component restricts the expected element by the properties of TopNavigationAction component.

Expected behavior: No ts errors. For example: Type ‘OverflowMenuProps’ is not assignable to type ‘TopNavigationActionProps’.

Related code:

  private renderRightControl = (): React.ReactElement<OverflowMenuProps> => {
    const { themedStyle } = this.props;

    return (
      <OverflowMenu
        style={themedStyle.menu}
        visible={this.state.menuVisible}
        placement='bottom end'
        items={this.items}
        onRequestClose={this.onMenuPress}
        onSelect={this.onMenuItemPress}>
        <TopNavigationAction
          icon={MenuIconAuth}
          onPress={this.onMenuPress}
        />
      </OverflowMenu>
    );
  };

  private renderRightControls = (): React.ReactElement<TopNavigationActionProps>[] => {
    return ([
      this.renderRightControl(),
    ]);
  };

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
artyorshcommented, Nov 19, 2019

Well, doing something like this will not break the ts build (this is simplified Top Navigation with Menu example).

Note the return type of the renderMenuAction function. It is TopNavigationActionElement but the actual rendered element is OverflowMenu. The code below will not throw ts errors.

import React from 'react';
import { Icon, OverflowMenu, TopNavigation, TopNavigationAction, TopNavigationActionElement } from 'react-native-ui-kitten';

const MenuIcon = (style) => (
  <Icon {...style} name='more-vertical'/>
);

export const TopNavigationWithMenuShowcase = () => {

  const renderMenuAction = (): TopNavigationActionElement => (
    <OverflowMenu>
      <TopNavigationAction icon={MenuIcon} onPress={toggleMenu} />
    </OverflowMenu>
  );

  return (
    <TopNavigation title='Application Title' rightControls={renderMenuAction()} />
  );
};
1reaction
32penkincommented, Sep 5, 2019

@ng-kode nice catch, thank you 😃 will refactor the documentation somehow…

Read more comments on GitHub >

github_iconTop Results From Across the Web

UI Kitten - Top Navigation - component overview - GitHub Pages
TopNavigation provides a heading component for the entire page. ... Rendering of React Native components in a web browser is an experimental feature...
Read more >
Navigation Component | Adobe Experience Manager
The Navigation Component allows users to easily navigate a globalized site structure.
Read more >
React Router Tutorial: Adding Navigation to your React App
In this React Router tutorial, you will learn how to add navigation throughout your single page application.
Read more >
Navbar
Ensure accessibility by using a <nav> element or, if using a more generic element such as a <div> , add a role="navigation" to...
Read more >
React Navbar Tutorial - Beginner React JS Project - YouTube
The navbar will be a navbar component and will include all the props and functions. If you've ever wondered, "How do you build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found