react-native-elements icon indicating copy to clipboard operation
react-native-elements copied to clipboard

Issue while using the elements with other react navigation/router

Open premcarver opened this issue 9 years ago • 3 comments

It's good to see that you have created a lot of reusable components.

But when I tried to use these components with 3-4 other navigation/router projects, None of them was working.

For example, first I tried it with Native-Navigation. While combining your elements I faced a lot of issues as they don't use the direct mapping of libraries. Somehow, I managed to link all required libraries like vector icons and PODs. Here I tried to use your native header elements which were not working as it went behind their navigation BAR(most probably). I was also not able to redirect from login page to dashboard which should have TAB BAR and Drawer.

Another instance was with React Native Router(https://github.com/aksonov/react-native-router-flux), again the same problem. Elements created by using your project was not compatible.

I expect to have a simple navigation/routing for various screens which may or may not have TAB/Drawer/Header at the different level of application flow. Could you please help to understand the navigation/routing scheme which is suitable for a big project.

Or

It would be good if you can guide/suggest me to choose best react navigation/routing project where I can use all of these elements(Specially Header/TAB/Drawer) smoothly.

Following are the screen where I have used the components but was not able to navigate to next page using react-router

screenshot 2017-09-14 21 06 33

/* @flow */

import React from 'react'
import { Platform, Image, View, Text, TouchableOpacity } from 'react-native'
import { BottomNavigation, Tab } from 'react-router-navigation'
import type { RouterHistory } from 'react-router'
import Feed from './Feed'
import Profile from './Profile'
import { NEUTRAL_COLOR_50, BRAND_COLOR_60 } from './theme'
import { Button, Header } from 'react-native-elements'
import { Link } from 'react-router-native'

import { FormLabel, FormInput, FormValidationMessage, Divider } from 'react-native-elements'


type Props = {
  history: RouterHistory,
}

class Login extends React.Component<void, Props, void> {
  props: Props
  feed: Feed

  shouldComponentUpdate(): boolean {
    return false
  }

  render(): React$Element<any> {
    const { history } = this.props
    return (
      <View style={{
        flex: 1,
        justifyContent: 'center',
        padding: 10,
        margin: 20
      }}>
        <Header
          centerComponent={{ text: 'Login', style: { color: '#000' } }}
        />
        <FormInput style={{ margin: 15, }} placeholder="Username" />

        <FormInput style={{ margin: 15, }} placeholder="Password" />

        <Text></Text>

        <Link
          replace
          component={TouchableOpacity}
          to="/feed"
        ><Button title='Login' /></Link></View>
    )
  }
}

export default Login

premcarver avatar Sep 14 '17 15:09 premcarver

The library react-navigation is recommended with react-native projects. But if you want to use react-native-element with your navigation, the best thing is to provide an onPress function to the button that redirect you to the good route. Try to see if a navigate action exists in your navigation lib.

You can do this:

<Button
  title='Login'
  onPress={() => navigate('/feed')}
/>

But the best is to use react-navigation.

For your header/tab bar/styling problem, the navigation library that you use is in charge of the render of these components. Components from react-native-elements are generics and independents, so you have to ask questions to your navigation lib

martinezguillaume avatar Sep 15 '17 12:09 martinezguillaume

Thank you for the recommendation. I will try to use react-navigation lib for my project. Thanks a lot :)

premcarver avatar Sep 16 '17 14:09 premcarver

what is your react-router version. I cannot import type { RouterHistory } from 'react-router'

txs avatar Apr 30 '18 19:04 txs