title: How to delegate third-party components in react-native ios
body: <p>I have following react native component in android.<br>
  parent class contains some common settings, 
  and some template code (eg. setData).</p>
  
  <h2>android version</h2>
  
  <p>parent component</p>
  
  <pre><code>public abstract class ParentComponent&lt;T extends Chart, U extends Entry&gt; extends SimpleViewManager {
      @ReactProp(name = "commonSettings")
      public void setCommonSettings(T chart, ReadableMap propMap) {
          // do common settings
      }
  
      abstract U createEntry(ReadableMap value);
  
      @ReactProp(name = "data")
      public void setData(Chart chart, ReadableArray values) {
          for (int i = 0; i &lt; values(); i++) {
              chart.addEntry(values.getMap(i));
          }
      }
  }
  </code></pre>
  
  <p>child component A</p>
  
  <pre><code>public class FooComponent extends ParentComponent&lt;FooChart, FooEntry&gt; {
      @Override
      public String getName() {
          return "FooChart";
     }
  
      @Override
      protected View createViewInstance(ThemedReactContext reactContext) {
          return new FooChart(reactContext);
      }
  
      @ReactProp(name = "fooSettings")
      public void setFooSettings(FooChart chart, ReadableMap propMap) {
          // do foo settings
      }
  
      @Override
      FooEntry createEntry(ReadableMap value) {
          return xxxxx;
      }   
  }
  </code></pre>
  
  <p>child component B</p>
  
  <pre><code>public class BarComponent extends ParentComponent&lt;BarChart, BarEntry&gt; {
      @Override
      public String getName() {
          return "BarChart";
     }
  
      @Override
      protected View createViewInstance(ThemedReactContext reactContext) {
          return new BarChart(reactContext);
      }
  
      @ReactProp(name = "barSettings")
      public void setBarSettings(FooChart chart, ReadableMap propMap) {
          // do foo settings
      }
  
      @Override
      BarEntry createEntry(ReadableMap value) {
          return xxxxx;
      }   
  }
  </code></pre>
  
  <h2>But How should I implement these in ios?</h2>
  
  <p>I am quite new to oc &amp; swift developing, here are my doubts.</p>
  
  <ul>
  <li><p>In ios, there need a RCTViewManager that return a UIView instance.<br>
  what shoud be the UIView instance?<br>
  I don't want to inherit FooChart &amp; BarChart, <em>delegate</em> is what I need.<br>
  So should I create a custom UIView, initialize a fooChart and holds its reference, then self.addSubView(fooChart) ?</p></li>
  <li><p>How to share the common settings and template code? Extension ?</p></li>
  <li><p>Do I have to duplicate <code>RCT_EXPORT_VIEW_PROPERTY(commonSettings, NSDictionary)</code> in both FooChartViewManager and BarChartViewManager?  </p></li>
  </ul>
  
  <p>I tried to define <code>class ParentComponentManagerSwift: RCTViewManager</code>,<br>
  and declare <code>RCT_EXPORT_VIEW_PROPERTY(commonSettings, NSDictionary)</code>  there,<br>
  and <code>class FooComponentManagerSwift: ParentComponentManager</code>, but it doesn't work.<br>
   But our components do inherit bunch of exports like backgroundColor/width/height  which declared in RCTViewManager?</p>