react-native-navigation的迁移库

stack-backButton.mdx 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---
  2. id: stack-backButton
  3. title: The Back button
  4. sidebar_label: Back button
  5. ---
  6. The back button is added automatically when two or more screens are pushed into the stack.
  7. ## Styling the back button
  8. The back button's style can be customised by declaring a backButton options object. This configuration can be part of a screen's static options, or default options.
  9. ```js
  10. backButton: {
  11. color: 'red',
  12. icon: require('../../img/customChevron.png')
  13. }
  14. ```
  15. ## Controling visibility
  16. The back buttons visbility can be controlled with the visible property.
  17. ```js
  18. backButton: {
  19. visible: false
  20. }
  21. ```
  22. ## Changing visbility programmatically
  23. Back button visibility can be changed dynamically using the mergeOptions command. When using a screen's componentId, the change will affect only that specific screen. But when using the stack's id, the change will affect all screens pushed into the stack.
  24. ```js
  25. Navigation.mergeOptions(this.props.componentId, {
  26. backButton: {
  27. visible: false
  28. }
  29. });
  30. ```
  31. ## Handling the back button
  32. Handling the back button is not possible. However, you can set a left button with a chevron and handle it like you'd handle any other button and calling `Navigation.pop` when desired.