web-server-example icon indicating copy to clipboard operation
web-server-example copied to clipboard

Icons doesnt appear using headerRight after react-navigation update ^3.0.0-rc.5

Open guptanisha opened this issue 5 years ago • 6 comments

'headerRight' icon doesn't appear when headerBackButton shows. Happening after updated react-navigation to version ^3.0.0-rc.5.

Any help would be appreciated!!

software | version react-navigation | 4.0.10 react-native | ^0.61.5 expo | 35 npm or yarn | npm

Current Behaviour:- Screen Shot 2020-01-08 at 3 37 42 PM

Expected Behaviour:- Screen Shot 2020-01-08 at 3 37 04 PM

static navigationOptions = ({ navigation }) => { const activityId = navigation.state.params.activity.id; let activity = Activities.getActivityById(activityId); const client = navigation.state.params.client; let responsiblePerson = getUserToNotify(client); let responsibleContactNumber = getResponsibleContactNumber(responsiblePerson);

    if (responsibleContactNumber != null) {
        var number = responsibleContactNumber.number;
        if (responsibleContactNumber.countryCode == "33") {
            if ( (number.charAt(0)) != 0 ) {
                number = "0" + number;
            }
        }
    }
    return {
        headerTitle: null,
        headerStyle: { backgroundColor: '#fff' },
        headerTintStyle: Styles.colorPrimary,
        headerRight: () => (
            <View style={{flexDirection: 'row'}}>
                {client.cellNumber || client.homeNumber ?
                <TouchableOpacity 
                onPress={() => responsibleContactNumber == null ? null : Communications.phonecall(number, true)} 
                style={{flex: 1, paddingTop: 10, paddingBottom: 10, paddingLeft: 10}}>
                    <FontAwesome 
                        name='phone' 
                        style={{paddingHorizontal: 10, color: Styles.colorPrimary}}
                        size={23} 
                    />
                </TouchableOpacity>
                : null }
                {client ?
                <TouchableOpacity 
                onPress={() => navigation.navigate('ClientTabs', {data: client, deleteAvailable: false})}
                style={{flex: 1, paddingTop: 10, paddingBottom: 10, paddingLeft: 10}}>
                    <FontAwesome 
                        name='user' 
                        style={{paddingHorizontal: 10, color: Styles.colorPrimary}}
                        size={23} 
                    />
                </TouchableOpacity>
                : null }
                { activity.isDeclined != true ?
                <TouchableOpacity 
                onPress={() => navigation.navigate('AppointmentEditor', { activityId: activityId, onGoBack: navigation.state.params.onGoBack })} 
                style={{flex: 1, paddingTop: 10, paddingBottom: 10, paddingLeft: 10}}>
                    <FontAwesome 
                        name='pencil-square-o' 
                        style={{paddingHorizontal: 10, color: Styles.colorPrimary}}
                        size={23} 
                    />
                </TouchableOpacity>
                : null }
            </View>
        )
    };  
};

guptanisha avatar Jan 08 '20 22:01 guptanisha

@satya164 also I tried to update React-Navigation 4.0, getting a new error
"Unable to resolve "./views/Header/Header" from "node_modules/react-navigation-stack/lib/module/index.js" Failed building JavaScript bundle."

Prompt help would be appreciable!!

guptanisha avatar Jan 09 '20 14:01 guptanisha

https://reactnavigation.org/docs/en/next/troubleshooting.html#im-getting-an-error-unable-to-resolve-module-after-updating-to-the-latest-version

satya164 avatar Jan 09 '20 16:01 satya164

@satya164 Thanks for the solution. It fixed the issue.

In the image below. Before the update icons in the header were appearing(Refer the left image), After icons don't appear also HeaderTitle appearing, HeaderBackButton behaves weirdly.

Really thankful.

Screen Shot 2020-01-09 at 4 11 59 PM

guptanisha avatar Jan 09 '20 21:01 guptanisha

@satya164 also drawer navigator doesn't open the toggle. Updated the code like below.

headerLeft: (
<TouchableOpacity onPress={() => navigation.toggleDrawer()} style={{padding: 10, paddingLeft: 15}}> <FontAwesome name='bars' size={23} style={{color: colorPrimary}} /> </TouchableOpacity> ),

guptanisha avatar Jan 09 '20 21:01 guptanisha

@brentvatne would help to suggest any solution.

thanks!

guptanisha avatar Jan 10 '20 20:01 guptanisha

@satya164 Thanks for the solution. It fixed the issue.

In the image below. Before the update icons in the header were appearing(Refer the left image), After icons don't appear also HeaderTitle appearing, HeaderBackButton behaves weirdly.

Really thankful.

Screen Shot 2020-01-09 at 4 11 59 PM

@satya164 @brentvatne Kindly suggest what I m doing wrong in above.

guptanisha avatar Jan 21 '20 14:01 guptanisha