Skip to content

App crashes if setBoolean called on initial screen #378

@Nezz

Description

@Nezz

Description

The first component we display calls setBoolean on mount:

  useEffect(() => {
    riveRef.current?.setBoolean('isFocused', isFocused);
  }, [isFocused]);

This causes the app to crash on iOS here:

let component = self.bridge.uiManager.view(forReactTag: node) as! RiveReactNativeView

rive_react_native/RiveReactNativeViewManager.swift:116: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Provide a Repro

export default function InitialComponent() {
  const [isFocused, setIsFocused] = useState(false);
  const riveRef = useRef<RiveRef>(null);

  useEffect(() => {
    riveRef.current?.setBoolean('isFocused', isFocused);
  }, [isFocused]);

  return (
    <Rive
      url="<somethign from the internet>"
      autoplay
      fit={Fit.Cover}
      style={StyleSheet.absoluteFillObject}
      ref={riveRef}
      dataBinding={AutoBind(true)}
    />
  );
}

Source .riv/.rev file

Not animation-specific

Expected behavior

The app should not crash

Screenshots

Not applicable

Device & Versions (please complete the following information)

  • Device: iPhone 17 Pro
  • OS: iOS 26.0.1
  • NPM Version: 10.9.3

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions