CodeBlanks Logo Icon CodeBlanks

Özet - Yeni mimari

JSI, Fabric ve TurboModules'ı birleştirerek bir yeni mimari özet yazarsın.

Özet - Yeni mimari

Yeni mimari üç temel taş üzerine kurulur: JSI (doğrudan C++ bağ), Fabric (yeni render katmanı) ve TurboModules (lazy native modüller). Codegen bu sistemlere native iskelet üretir.

Köprü (bridge) kalkar; seri hale getirme gider; senkron çağrılar mümkün olur. React 18 concurrent render ile Fabric uyumludur. React Native 0.74'ten itibaren varsayılan açık.

Uygulama TurboModule çağrısını yaz

Bir Math TurboModule'ünü TurboModuleRegistry.getEnforcing ile al. Spec tipini generic olarak ver. Sonucu MathModule değişkenine ata.

Başlangıç kodu

App.js
import { TurboModuleRegistry } from 'react-native';
import type { Spec } from './NativeMath';

// Module'ü buraya al

export default MathModule;

Örnek çözüm

App.js
import { TurboModuleRegistry } from 'react-native';
import type { Spec } from './NativeMath';

const MathModule = TurboModuleRegistry.getEnforcing<Spec>('Math');

export default MathModule;

Uygulama Fabric native bileşenini dışa aktar

NativeProps arayüzü ile Box adında Fabric native bileşeni tanımla. codegenNativeComponent kullan; sonucu default export et.

Başlangıç kodu

App.js
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';

interface NativeProps {
  color?: string;
}

// Box bileşenini buraya tanımla ve dışa aktar

Örnek çözüm

App.js
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';

interface NativeProps {
  color?: string;
}

const Box = codegenNativeComponent<NativeProps>('Box');
export default Box;

Soru ve cevaplar

Dersin sorularını cevaplarıyla birlikte inceleyebilirsin. Kendini denemek istersen dersi interaktif olarak çöz.

1 Yeni mimarinin temel taşları hangileri?

  • Bridge, Async, JSON
  • JSI, Fabric, TurboModules Doğru cevap
  • CSS, HTML, DOM
  • Webpack, Babel, ESLint

Açıklama: Üç temel taş JSI, Fabric ve TurboModules'tür.

2 Tüm parçaları eşleştir

Kavram Anlamı
JSI Doğrudan C++ bağ
Fabric Render katmanı
TurboModules Lazy modüller
Codegen İskelet üretici

Uzman bölümündeki tüm dersler