Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a component as stack navigator title throws when navigating away #3043

Closed
albertogasparin opened this issue Nov 24, 2017 · 5 comments
Closed
Assignees

Comments

@albertogasparin
Copy link

albertogasparin commented Nov 24, 2017

I've found out that when setting a component as navigationOptions.title, react-navigation tries to use it as a text for the back button of the next screen. Hoverer, if the component is not serializable, react will throw several errors like:

Malformed calls from JS: field sizes are different.
# and
TypeError: Converting circular structure to JSON

The code could be as dummy as:

class Home extends Component {
  static navigationOptions = () => ({
    title: <Text>Title</Text>,
  });
}

The solution is setting navigationOptions.headerBackTitle, so explicitly providing a string to be used on the back button. However the error makes this simple fix hard to spot.

Expected Behavior

I think react-navigation should check whenever navigationOptions.title is a string, and if not use the same headerTruncatedBackTitledefault text.

Environment

software version
react-navigation 1.0.0-beta.21
react-native 0.50.3
node 8.4.0
@kelset
Copy link

kelset commented Nov 24, 2017

Does it happen also with latest release?

@albertogasparin
Copy link
Author

Yes it does, just updated now to 1.0.0-beta.21 (I've also updated the version on the issue)

@kelset
Copy link

kelset commented Nov 24, 2017

Ok thanks for reporting, it looks like the proposed solution is a viable one.
We'll try to work on it asap (but ofc a PR is surely welcome).

@brentvatne
Copy link
Member

this should be headerTitle and not title. but we need to warn better if people don't provide a string here.

@brentvatne
Copy link
Member

see #4058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants