Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

renderBottomAccessoryView crashes on iOS 26: RCTBottomAccessoryComponentView does not initialize _props in its constructor

未关闭 适合新手
#607 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
92/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ios, objective-c, react-native
领域
frontend, mobile

调研方向

从ios/RCTBottomAccessoryComponentView.mm开始,将initWithFrame:的设置与RCTTabViewComponentView.mm进行比较,issue将后者列为可正常工作的示例。将现有的defaultProps赋给_props,然后在iOS 26的Debug模式下使用renderBottomAccessoryView构建并运行提供的示例;当附件视图挂载时没有触发assertion,并显示在标签栏上方,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug
Before submitting a new issue
  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.
Bug summary

Description

Using the iOS 26 bottom accessory feature (renderBottomAccessoryView) crashes the app
immediately on first render:

Thread 1: "`RCTViewComponentView` subclasses (and `RCTBottomAccessoryComponentView`
particularly) must setup `_props` instance variable with a default value in the constructor."

Removing renderBottomAccessoryView makes the app run normally, so the crash is specific to
the accessory component view.

Library version

1.5.0

Environment info
info Fetching system and libraries information...
System:
  OS: macOS 26.5.2
  CPU: (10) arm64 Apple M4
  Memory: 87.67 MB / 24.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.18.0
    path: /var/folders/lt/t4vyv6s110d1p6mg8_fwsd9h0000gn/T/yarn--1793087516853-0.2936365526559257/node
  Yarn:
    version: 1.22.22
    path: /var/folders/lt/t4vyv6s110d1p6mg8_fwsd9h0000gn/T/yarn--1793087516853-0.2936365526559257/yarn
  npm:
    version: 11.16.0
    path: /Users/munitcat/.vfox/sdks/nodejs/bin/npm
  Watchman:
    version: 2026.07.20.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.17.0
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.5
      - iOS 26.5
      - macOS 26.5
      - tvOS 26.5
      - visionOS 26.5
      - watchOS 26.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2026.1 AI-261.25134.95.2612.15822958
  Xcode:
    version: 26.6/17F113
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.18
    path: /usr/bin/javac
  Ruby:
    version: 4.0.6
    path: /opt/homebrew/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.2.0
    wanted: 20.2.0
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.88.0
    wanted: 0.88.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Steps to reproduce

Root cause

ios/RCTBottomAccessoryComponentView.mm — initWithFrame: creates defaultProps but never
assigns it to the _props ivar:

- (instancetype)initWithFrame:(CGRect)frame
{
  if (self = [super initWithFrame:frame]) {
    static const auto defaultProps = std::make_shared<const BottomAccessoryViewProps>();
    if (@available(iOS 26.0, *)) {          // <-- defaultProps is never used
      bottomAccessoryProvider = [[BottomAccessoryProvider alloc] initWithDelegate:self];
    }
  }
  return self;
}

RCTViewComponentView (react-native 0.88.0,
React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm:137) initializes the ivar
with plain ViewProps:

_props = ViewShadowNode::defaultSharedProps();

and then asserts in updateProps:oldProps: (line 333–346) that every subclass replaces it with
its own props type:

RCTAssert(
    propsRawPtr &&
        ([self class] == [RCTViewComponentView class] ||
         typeid(*propsRawPtr).hash_code() != typeid(const ViewProps).hash_code()),
    @"`RCTViewComponentView` subclasses (and `%@` particularly) must setup `_props`"
     " instance variable with a default value in the constructor.",
    NSStringFromClass([self class]));

Because RCTBottomAccessoryComponentView never overrides _props, typeid(*_props) is still
ViewProps and the assertion fires.

For comparison, RCTTabViewComponentView.mm does it correctly in the same constructor:

static const auto defaultProps = std::make_shared<const RNCTabViewProps>();
...
self.contentView = _tabViewProvider;
_props = defaultProps;   // <-- this line is missing in the accessory view

Fix

One line, in ios/RCTBottomAccessoryComponentView.mm:

   if (self = [super initWithFrame:frame]) {
     static const auto defaultProps = std::make_shared<const BottomAccessoryViewProps>();
+    _props = defaultProps;
     if (@available(iOS 26.0, *)) {

This also silences the unused variable 'defaultProps' compiler warning.

Scope / notes

  • Only affects builds with the New Architecture, as the file is wrapped in
    #ifdef RCT_NEW_ARCH_ENABLED.
  • Only triggered when renderBottomAccessoryView is provided and
    Platform.Version >= 26 — that is the only path where BottomAccessoryView is mounted
    (src/TabView.tsx, around line 522).
  • Debug only. The assertion sits inside #ifndef NS_BLOCK_ASSERTIONS, so it is compiled
    out in Release. Release builds don't crash, but the component view keeps running on the
    base ViewProps instead of its own props type.

Workaround

Until a release with the fix is out, apply the patch through patch-package:

npm i -D patch-package
npx patch-package react-native-bottom-tabs

and add "postinstall": "patch-package" to package.json.
The generated patch is attached below.

diff --git a/node_modules/react-native-bottom-tabs/ios/RCTBottomAccessoryComponentView.mm b/node_modules/react-native-bottom-tabs/ios/RCTBottomAccessoryComponentView.mm
--- a/node_modules/react-native-bottom-tabs/ios/RCTBottomAccessoryComponentView.mm
+++ b/node_modules/react-native-bottom-tabs/ios/RCTBottomAccessoryComponentView.mm
@@ -40,6 +40,7 @@ - (instancetype)initWithFrame:(CGRect)frame
 {
   if (self = [super initWithFrame:frame]) {
     static const auto defaultProps = std::make_shared<const BottomAccessoryViewProps>();
+    _props = defaultProps;
     if (@available(iOS 26.0, *)) {
 #if SWIFT_PACKAGE
       bottomAccessoryProvider = RNCCreateBottomAccessoryProvider(self);

Alternatively, simply do not pass renderBottomAccessoryView — the tab bar itself works fine
without it.

Reproducible sample code
## Steps to reproduce


import TabView from 'react-native-bottom-tabs';

const routes = [
  { key: 'home', title: 'Home', focusedIcon: { sfSymbol: 'house.fill' } },
];

<TabView
  navigationState={{ index: 0, routes }}
  renderScene={() => <View />}
  onIndexChange={() => {}}
  renderBottomAccessoryView={() => <View style={{ height: 44 }} />}
/>


Run on an **iOS 26** device or simulator in **Debug**. The app crashes while mounting the  
`BottomAccessoryView` component.Expected

The bottom accessory renders above the tab bar.
主要语言
TypeScript
星标
1.5k
派生
111
平均合并
2 天 1 小时
30 天内合并 PR
6

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstack/react-native-bottom-tabs 的其他 Issue

查看 callstack/react-native-bottom-tabs 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。