Skip to content

Commit 4ee2e9b

Browse files
authored
chore: move native component and module docs to legacy (facebook#4243)
1 parent bf15be9 commit 4ee2e9b

15 files changed

+61
-35
lines changed

docs/animations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ This example uses a preset value, you can customize the animations as you need,
671671

672672
### `setNativeProps`
673673

674-
As mentioned [in the Direct Manipulation section](direct-manipulation), `setNativeProps` allows us to modify properties of native-backed components (components that are actually backed by native views, unlike composite components) directly, without having to `setState` and re-render the component hierarchy.
674+
As mentioned [in the Direct Manipulation section](legacy/direct-manipulation), `setNativeProps` allows us to modify properties of native-backed components (components that are actually backed by native views, unlike composite components) directly, without having to `setState` and re-render the component hierarchy.
675675

676676
We could use this in the Rebound example to update the scale - this might be helpful if the component that we are updating is deeply nested and hasn't been optimized with `shouldComponentUpdate`.
677677

docs/communication-android.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Communication between native and React Native
55

66
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
77

8-
In [Integrating with Existing Apps guide](integration-with-existing-apps) and [Native UI Components guide](native-components-android) we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques.
8+
In [Integrating with Existing Apps guide](integration-with-existing-apps) and [Native UI Components guide](legacy/native-components-android) we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques.
99

1010
## Introduction
1111

@@ -118,13 +118,13 @@ There is no way to update only a few properties at a time. We suggest that you b
118118
119119
### Passing properties from React Native to native
120120

121-
The problem exposing properties of native components is covered in detail in [this article](native-components-android#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation). In short, properties that are to be reflected in JavaScript needs to be exposed as setter method annotated with `@ReactProp`, then use them in React Native as if the component was an ordinary React Native component.
121+
The problem exposing properties of native components is covered in detail in [this article](legacy/native-components-android#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation). In short, properties that are to be reflected in JavaScript needs to be exposed as setter method annotated with `@ReactProp`, then use them in React Native as if the component was an ordinary React Native component.
122122

123123
### Limits of properties
124124

125125
The main drawback of cross-language properties is that they do not support callbacks, which would allow us to handle bottom-up data bindings. Imagine you have a small RN view that you want to be removed from the native parent view as a result of a JS action. There is no way to do that with props, as the information would need to go bottom-up.
126126

127-
Although we have a flavor of cross-language callbacks ([described here](native-modules-android#callbacks)), these callbacks are not always the thing we need. The main problem is that they are not intended to be passed as properties. Rather, this mechanism allows us to trigger a native action from JS, and handle the result of that action in JS.
127+
Although we have a flavor of cross-language callbacks ([described here](legacy/native-modules-android#callbacks)), these callbacks are not always the thing we need. The main problem is that they are not intended to be passed as properties. Rather, this mechanism allows us to trigger a native action from JS, and handle the result of that action in JS.
128128

129129
## Other ways of cross-language interaction (events and native modules)
130130

@@ -134,7 +134,7 @@ React Native enables you to perform cross-language function calls. You can execu
134134

135135
### Calling React Native functions from native (events)
136136

137-
Events are described in detail in [this article](native-components-android#events). Note that using events gives us no guarantees about execution time, as the event is handled on a separate thread.
137+
Events are described in detail in [this article](legacy/native-components-android#events). Note that using events gives us no guarantees about execution time, as the event is handled on a separate thread.
138138

139139
Events are powerful, because they allow us to change React Native components without needing a reference to them. However, there are some pitfalls that you can fall into while using them:
140140

@@ -144,6 +144,6 @@ Events are powerful, because they allow us to change React Native components wit
144144

145145
### Calling native functions from React Native (native modules)
146146

147-
Native modules are Java/Kotlin classes that are available in JS. Typically one instance of each module is created per JS bridge. They can export arbitrary functions and constants to React Native. They have been covered in detail in [this article](native-modules-android).
147+
Native modules are Java/Kotlin classes that are available in JS. Typically one instance of each module is created per JS bridge. They can export arbitrary functions and constants to React Native. They have been covered in detail in [this article](legacy/native-modules-android).
148148

149149
> **_Warning_**: All native modules share the same namespace. Watch out for name collisions when creating new ones.

docs/communication-ios.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: communication-ios
33
title: Communication between native and React Native
44
---
55

6-
In [Integrating with Existing Apps guide](integration-with-existing-apps) and [Native UI Components guide](native-components-ios) we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques.
6+
In [Integrating with Existing Apps guide](integration-with-existing-apps) and [Native UI Components guide](legacy/native-components-ios) we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques.
77

88
## Introduction
99

@@ -65,13 +65,13 @@ There is no way to update only a few properties at a time. We suggest that you b
6565
6666
### Passing properties from React Native to native
6767
68-
The problem exposing properties of native components is covered in detail in [this article](native-components-ios#properties). In short, export properties with `RCT_CUSTOM_VIEW_PROPERTY` macro in your custom native component, then use them in React Native as if the component was an ordinary React Native component.
68+
The problem exposing properties of native components is covered in detail in [this article](legacy/native-components-ios#properties). In short, export properties with `RCT_CUSTOM_VIEW_PROPERTY` macro in your custom native component, then use them in React Native as if the component was an ordinary React Native component.
6969
7070
### Limits of properties
7171
7272
The main drawback of cross-language properties is that they do not support callbacks, which would allow us to handle bottom-up data bindings. Imagine you have a small RN view that you want to be removed from the native parent view as a result of a JS action. There is no way to do that with props, as the information would need to go bottom-up.
7373
74-
Although we have a flavor of cross-language callbacks ([described here](native-modules-ios#callbacks)), these callbacks are not always the thing we need. The main problem is that they are not intended to be passed as properties. Rather, this mechanism allows us to trigger a native action from JS, and handle the result of that action in JS.
74+
Although we have a flavor of cross-language callbacks ([described here](legacy/native-modules-ios#callbacks)), these callbacks are not always the thing we need. The main problem is that they are not intended to be passed as properties. Rather, this mechanism allows us to trigger a native action from JS, and handle the result of that action in JS.
7575
7676
## Other ways of cross-language interaction (events and native modules)
7777
@@ -81,7 +81,7 @@ React Native enables you to perform cross-language function calls. You can execu
8181
8282
### Calling React Native functions from native (events)
8383
84-
Events are described in detail in [this article](native-components-ios#events). Note that using events gives us no guarantees about execution time, as the event is handled on a separate thread.
84+
Events are described in detail in [this article](legacy/native-components-ios#events). Note that using events gives us no guarantees about execution time, as the event is handled on a separate thread.
8585
8686
Events are powerful, because they allow us to change React Native components without needing a reference to them. However, there are some pitfalls that you can fall into while using them:
8787
@@ -93,7 +93,7 @@ The common pattern we use when embedding native in React Native is to make the n
9393
9494
### Calling native functions from React Native (native modules)
9595
96-
Native modules are Objective-C classes that are available in JS. Typically one instance of each module is created per JS bridge. They can export arbitrary functions and constants to React Native. They have been covered in detail in [this article](native-modules-ios#content).
96+
Native modules are Objective-C classes that are available in JS. Typically one instance of each module is created per JS bridge. They can export arbitrary functions and constants to React Native. They have been covered in detail in [this article](legacy/native-modules-ios#content).
9797
9898
The fact that native modules are singletons limits the mechanism in the context of embedding. Let's say we have a React Native component embedded in a native view and we want to update the native, parent view. Using the native module mechanism, we would export a function that not only takes expected arguments, but also an identifier of the parent native view. The identifier would be used to retrieve a reference to the parent view to update. That said, we would need to keep a mapping from identifiers to native views in the module.
9999
@@ -111,7 +111,7 @@ When integrating native and React Native, we also need a way to consolidate two
111111
112112
### Layout of a native component embedded in React Native
113113
114-
This case is covered in [this article](native-components-ios#styles). To summarize, since all our native react views are subclasses of `UIView`, most style and size attributes will work like you would expect out of the box.
114+
This case is covered in [this article](legacy/native-components-ios#styles). To summarize, since all our native react views are subclasses of `UIView`, most style and size attributes will work like you would expect out of the box.
115115
116116
### Layout of a React Native component embedded in native
117117

docs/intro-react-native-components.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ In Android development, you write views in Kotlin or Java; in iOS development, y
2323

2424
React Native comes with a set of essential, ready-to-use Native Components you can use to start building your app today. These are React Native's **Core Components**.
2525

26-
React Native also lets you build your own Native Components for [Android](native-components-android.md) and [iOS](native-components-ios.md) to suit your app’s unique needs. We also have a thriving ecosystem of these **community-contributed components.** Check out [Native Directory](https://reactnative.directory) to find what the community has been creating.
26+
:::caution
27+
This documentation references a legacy set of API and needs to be updated to reflect the New Architecture
28+
:::
29+
React Native also lets you build your own Native Components for [Android](legacy/native-components-android.md) and [iOS](legacy/native-components-ios.md) to suit your app’s unique needs. We also have a thriving ecosystem of these **community-contributed components.** Check out [Native Directory](https://reactnative.directory) to find what the community has been creating.
2730

2831
## Core Components
2932

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export default App;
270270
</TabItem>
271271
</Tabs>
272272

273-
You can use the [`clear`](textinput#clear) method to clear the `TextInput` which clears the current input text using the same approach.
273+
You can use the [`clear`](../textinput#clear) method to clear the `TextInput` which clears the current input text using the same approach.
274274

275275
## Avoiding conflicts with the render function
276276

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Android Native UI Components
44
---
55

66
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
7-
import NativeDeprecated from './the-new-architecture/\_markdown_native_deprecation.mdx'
7+
import NativeDeprecated from '../the-new-architecture/\_markdown_native_deprecation.mdx'
88

99
<NativeDeprecated />
1010

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: native-components-ios
33
title: iOS Native UI Components
44
---
55

6-
import NativeDeprecated from './the-new-architecture/\_markdown_native_deprecation.mdx'
6+
import NativeDeprecated from '../the-new-architecture/\_markdown_native_deprecation.mdx'
77

88
<NativeDeprecated />
99

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: native-modules-android
33
title: Android Native Modules
44
---
55

6-
import NativeDeprecated from './the-new-architecture/\_markdown_native_deprecation.mdx'
6+
import NativeDeprecated from '../the-new-architecture/\_markdown_native_deprecation.mdx'
77
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
88

99
<NativeDeprecated />
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: native-modules-intro
33
title: Native Modules Intro
44
---
55

6-
import NativeDeprecated from './the-new-architecture/\_markdown_native_deprecation.mdx'
6+
import NativeDeprecated from '../the-new-architecture/\_markdown_native_deprecation.mdx'
77

88
<NativeDeprecated />
99

@@ -23,7 +23,7 @@ This guide will first walk you through implementing a native module directly wit
2323

2424
## Getting Started
2525

26-
In the following sections we will walk you through guides on how to build a native module directly within a React Native application. As a prerequisite, you will need a React Native application to work within. You can follow the steps [here](getting-started) to setup a React Native application if you do not already have one.
26+
In the following sections we will walk you through guides on how to build a native module directly within a React Native application. As a prerequisite, you will need a React Native application to work within. You can follow the steps [here](../getting-started) to setup a React Native application if you do not already have one.
2727

2828
Imagine that you want to access the iOS/Android native calendar APIs from JavaScript within a React Native application in order to create calendar events. React Native does not expose a JavaScript API to communicate with the native calendar libraries. However, through native modules, you can write native code that communicates with native calendar APIs. Then you can invoke that native code through JavaScript in your React Native application.
2929

0 commit comments

Comments
 (0)