Branch integration error: TypeError: Cannot read property 'showShareSheet' of undefined


I’m trying to integrate into our CRNA/Expo app. I have followed the documentation, and only changed minor things to make it fit our project.

When clicking the designated button we get the following error:

Possible Unhandled Promise Rejection (id: 1):
TypeError: Cannot read property 'showShareSheet' of undefined
TypeError: Cannot read property 'showShareSheet' of undefined
    at ShareButton._onShareLinkPress$ (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:156604:76)
    at tryCatch (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:17044:19)
    at Generator.invoke [as _invoke] (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:17217:24)
    at Generator.prototype.(anonymous function) [as next] (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:17087:23)
    at tryCatch (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:17044:19)
    at invoke (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:17120:22)
    at blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:17148:13
    at tryCallTwo (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:16382:7)
    at doResolve (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:16546:15)
    at new Promise (blob:file:///38d00e7c-a980-4285-ad3f-f1d562013495:16405:5)

This is the code:

import React, { Component } from 'react';
import { TouchableOpacity, Share, Platform, Alert } from 'react-native';
import { DangerZone } from 'expo';
import PropTypes from 'prop-types';
import styles from './shareButtonStyles.js';
import globalStyles from '@utils/globalStyles';

import Icon from '@components/Icon/Icon';

class ShareButton extends Component {
  componentDidMount() {

  render() {
    return (
    <TouchableOpacity style={[styles.container,]} onPress={this._onShareLinkPress.bind(this)}>

  _share() {
    let shareObj = {
      title: this.props.title,
    if (Platform.OS === 'ios') {
      shareObj.url =;
      shareObj.subject = 'share Pj recipe';
    } else {
      shareObj.dialogTitle = 'share Pj recipe';
      .then(result => console.log(result))
      .catch(error => console.log(error));

  async _createBranchUniversalObject() {
    const { recipe } = this.props.recipe;
    this._branchUniversalObject = await DangerZone.Branch.createBranchUniversalObject(
        title: recipe.title,
        contentImageUrl: recipe.thumbnail,
        contentDescription: recipe.description,
        // This metadata can be used to easily navigate back to this screen
        // when implementing deep linking with `Branch.subscribe`.
        metadata: {
          screen: 'recipeScreen',
          params: JSON.stringify({ recipeId: }),

  async _onShareLinkPress() {
    const shareOptions = {
      messageHeader: this.props.recipe.title,
      messageBody: `Checkout my new recipe!`,
    await this._branchUniversalObject.showShareSheet(shareOptions);

ShareButton.propTypes = {
  link: PropTypes.string.isRequired,
  title: PropTypes.string.isRequired,
  style: PropTypes.object,

export default ShareButton;

I have already tried building it as a standalone app. The button remains unresponsive.

It seems like this._branchUniversalObject doesn’t get initialized when this._createBranchUniversalObject() is called. Notice the two alerts in that function. The first one gets called, the second one doesn’t. Perhaps DangerZone.Branch.createBranchUniversalObject() never returns the promise.

Any help would be greatly appreciated.

cc @janic

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.