Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

325
Views
cómo pasar un componente de reacción como una propiedad de vista nativa

Estoy tratando de crear una aplicación nativa de reacción con algunos componentes de interfaz de usuario nativos y algunos componentes de React. Quiero un componente de interfaz de usuario nativo que tome un componente de reacción como propiedad y lo represente como una subvista.

Pasé por el proceso normal de hacer un componente ui nativo y usé RCT_EXPORT_VIEW_PROPERTY(view, RCTView) para obtener la propiedad view.

PagedUIViewManager.swift:

 @objc(PagedUIViewManager) class PagedUIViewManager: RCTViewManager { override func view() -> UIView! { return PagedUIView(); } override static func requiresMainQueueSetup() -> Bool { return true } }

PagedUIView.swift:

 class PagedUIView: UIView { @objc var view: UIView { didSet { for subview in self.subviews { subview.removeFromSuperview() } self.addSubview(view) } } override init(frame: CGRect) { self.view = UIView(frame: frame) super.init(frame: frame) self.addSubview(view) } }

PagedUIViewManager.m:

 #import "React/RCTViewManager.h" @interface RCT_EXTERN_MODULE(PagedUIViewManager, RCTViewManager) RCT_EXPORT_VIEW_PROPERTY(view, RCTView) @end

PagedUINativeView.js:

 const PagedUI = requireNativeComponent("PagedUIView"); export default class PagedUIView extends React.Component { render() { return <PagedUI {...this.props}/>; } }

uso:

 <PagedUIView view={<ComponentToRender />} />

Esperaba que la vista mostrara <ComponentToRender /> , pero en su lugar aparece el error de tiempo de ejecución "Violación invariable: 435,PagedView,1,[object Object] no se puede usar como argumento de método nativo".

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Actualmente no es posible, la única forma de pasar vistas a módulos nativos pasa la vista como hijos.

Puede recibir la vista usando:

 @objc override func insertReactSubview(_ subview: UIView!, at atIndex: Int)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!