Skip to content

Commit 94c5e80

Browse files
authored
fix: remove isFabricEnabled check from docs (facebook#3336)
* fix: remove isFabricEnabled check * fix: language lint
1 parent b55bdc6 commit 94c5e80

File tree

2 files changed

+6
-56
lines changed

2 files changed

+6
-56
lines changed

docs/the-new-architecture/backward-compatibility-fabric-components.md

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ For a Fabric Native Component, the source of truth is the `<YourModule>NativeCom
416416
import MyComponent from 'your-component/src/index';
417417
```
418418

419-
The **goal** is to conditionally `export` the proper object from the `index` file , given the architecture chosen by the user. We can achieve this with a code that looks like this:
419+
Since `codegenNativeComponent` is calling the `requireNativeComponent` under the hood, we need to re-export our component, to avoid registering it multiple times.
420420

421421
<Tabs groupId="fabric-component-backward-compatibility"
422422
defaultValue={constants.defaultFabricComponentSpecLanguage}
@@ -425,40 +425,15 @@ The **goal** is to conditionally `export` the proper object from the `index` fil
425425

426426
```ts
427427
// @flow
428-
import { requireNativeComponent } from 'react-native';
429-
430-
const isFabricEnabled = global.nativeFabricUIManager != null;
431-
432-
const myComponent = isFabricEnabled
433-
? require('./MyComponentNativeComponent').default
434-
: requireNativeComponent('MyComponent');
435-
436-
export default myComponent;
428+
export default require('./MyComponentNativeComponent').default;
437429
```
438430

439431
</TabItem>
440432
<TabItem value="TypeScript">
441433

442434
```ts
443-
import requireNativeComponent from 'react-native/Libraries/ReactNative/requireNativeComponent';
444-
445-
const isFabricEnabled = global.nativeFabricUIManager != null;
446-
447-
const myComponent = isFabricEnabled
448-
? require('./MyComponentNativeComponent').default
449-
: requireNativeComponent('MyComponent');
450-
451-
export default myComponent;
435+
export default require('./MyComponentNativeComponent').default;
452436
```
453437

454438
</TabItem>
455439
</Tabs>
456-
457-
Whether you are using Flow or TypeScript for your specs, we understand which architecture is running by checking if the `global.nativeFabricUIManager` object has been set or not.
458-
459-
:::caution
460-
Please note that the New Architecture is still experimental. The `global.nativeFabricUIManager` API might change in the future for a function that encapsulate this check.
461-
:::
462-
463-
- If that object is `null`, then the app has not enabled the Fabric feature. It's running on the Old Architecture, and the fallback is to use the default Legacy Native Components implementation ([iOS](../native-components-ios) or [Android](../native-components-android)).
464-
- If that object is set, the app is running with Fabric enabled, and it should use the `<MyComponent>NativeComponent` spec to access the Fabric Native Component.

website/versioned_docs/version-0.70/the-new-architecture/backward-compatibility-fabric-components.md

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ For a Fabric Native Component, the source of truth is the `<YourModule>NativeCom
394394
import MyComponent from 'your-component/src/index';
395395
```
396396

397-
The **goal** is to conditionally `export` from the `index` file the proper object, given the architecture chosen by the user. We can achieve this with a code that looks like this:
397+
Since `codegenNativeComponent` is calling the `requireNativeComponent` under the hood, we need to re-export our component, to avoid registering it multiple times.
398398

399399
<Tabs groupId="fabric-component-backward-compatibility"
400400
defaultValue={constants.defaultFabricComponentSpecLanguage}
@@ -403,40 +403,15 @@ The **goal** is to conditionally `export` from the `index` file the proper objec
403403

404404
```ts
405405
// @flow
406-
import { requireNativeComponent } from 'react-native';
407-
408-
const isFabricEnabled = global.nativeFabricUIManager != null;
409-
410-
const myComponent = isFabricEnabled
411-
? require('./MyComponentNativeComponent').default
412-
: requireNativeComponent('MyComponent');
413-
414-
export default myComponent;
406+
export default require('./MyComponentNativeComponent').default;
415407
```
416408

417409
</TabItem>
418410
<TabItem value="TypeScript">
419411

420412
```ts
421-
import requireNativeComponent from 'react-native/Libraries/ReactNative/requireNativeComponent';
422-
423-
const isFabricEnabled = global.nativeFabricUIManager != null;
424-
425-
const myComponent = isFabricEnabled
426-
? require('./MyComponentNativeComponent').default
427-
: requireNativeComponent('MyComponent');
428-
429-
export default myComponent;
413+
export default require('./MyComponentNativeComponent').default;
430414
```
431415

432416
</TabItem>
433417
</Tabs>
434-
435-
Whether you are using Flow or TypeScript for your specs, we understand which architecture is running by checking if the `global.nativeFabricUIManager` object has been set or not.
436-
437-
:::caution
438-
Please note that the New Architecture is still experimental. The `global.nativeFabricUIManager` API might change in the future for a function that encapsulate this check.
439-
:::
440-
441-
- If that object is `null`, then the app has not enabled the Fabric feature. It's running on the Old Architecture, and the fallback is to use the default Legacy Native Components implementation ([iOS](../native-components-ios) or [Android](../native-components-android)).
442-
- If that object is set, the app is running with Fabric enabled, and it should use the `<MyComponent>NativeComponent` spec to access the Fabric Native Component.

0 commit comments

Comments
 (0)