Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/debugging-native-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ adb logcat "*:S" ReactNative:V ReactNativeJS:V YourModuleName:D

In your native module, use `NSLog` for custom logs:

```objective-c
```objectivec
NSLog(@"YourModuleName: %@", message);
```

Expand Down
12 changes: 6 additions & 6 deletions docs/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ React Native provides the [Fetch API](https://developer.mozilla.org/en-US/docs/W

In order to fetch content from an arbitrary URL, you can pass the URL to fetch:

```tsx
```ts
fetch('https://mywebsite.com/mydata.json');
```

Fetch also takes an optional second argument that allows you to customize the HTTP request. You may want to specify additional headers, or make a POST request:

```tsx
```ts
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
Expand All @@ -43,7 +43,7 @@ The above examples show how you can make a request. In many cases, you will want

Networking is an inherently asynchronous operation. Fetch method will return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that makes it straightforward to write code that works in an asynchronous manner:

```tsx
```ts
const getMoviesFromApi = () => {
return fetch('https://reactnative.dev/movies.json')
.then(response => response.json())
Expand All @@ -58,7 +58,7 @@ const getMoviesFromApi = () => {

You can also use the `async` / `await` syntax in a React Native app:

```tsx
```ts
const getMoviesFromApiAsync = async () => {
try {
const response = await fetch(
Expand Down Expand Up @@ -199,7 +199,7 @@ On Android, as of API Level 28, clear text traffic is also blocked by default. T

The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is built into React Native. This means that you can use third party libraries such as [frisbee](https://github.com/niftylettuce/frisbee) or [axios](https://github.com/axios/axios) that depend on it, or you can use the XMLHttpRequest API directly if you prefer.

```tsx
```ts
const request = new XMLHttpRequest();
request.onreadystatechange = e => {
if (request.readyState !== 4) {
Expand All @@ -225,7 +225,7 @@ The security model for XMLHttpRequest is different than on web as there is no co

React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.

```tsx
```ts
const ws = new WebSocket('ws://host.com/path');

ws.onopen = () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ One reason why well-built native apps feel so smooth is by avoiding expensive op

Applications can schedule tasks to run after interactions with the following:

```tsx
```ts
InteractionManager.runAfterInteractions(() => {
// ...long-running synchronous task...
});
Expand All @@ -49,7 +49,7 @@ The touch handling system considers one or more active touches to be an 'interac

`InteractionManager` also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:

```tsx
```ts
const handle = InteractionManager.createInteractionHandle();
// run animation... (`runAfterInteractions` tasks are queued)
// later, on animation completion:
Expand Down
32 changes: 29 additions & 3 deletions plugins/remark-codeblock-language-as-title/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,44 @@

import {Root} from 'mdast';

const LANGUAGES_MAP: Record<string, string> = {
js: 'JavaScript',
javascript: 'JavaScript',
ts: 'TypeScript',
typescript: 'TypeScript',
jsx: 'React JSX',
tsx: 'React TSX',
json: 'JSON',
objc: 'Objective-C',
objectivec: 'Objective-C',
xml: 'XML',
css: 'CSS',
cpp: 'C++',
};

const HIDDEN_TITLES = ['zsh', 'sh', 'shell', 'bash', 'powershell'];

function capitalizeFirstLetter(str: string | null) {
if (!str) {
return str;
}
return str[0].toUpperCase() + str.slice(1);
}

export default function codeblockLanguageAsTitleRemarkPlugin() {
return async (root: Root) => {
const {visit} = await import('unist-util-visit');
visit(root, 'code', node => {
if (node.lang && !['shell', 'bash'].includes(node.lang)) {
if (node.lang && !HIDDEN_TITLES.includes(node.lang)) {
const formattedTitle =
LANGUAGES_MAP[node.lang] ?? capitalizeFirstLetter(node.lang);
if (node.meta) {
if (node.meta.includes('title=')) {
return;
}
node.meta = `title="${node.lang}" ${node.meta}`;
node.meta = `title="${formattedTitle}" ${node.meta}`;
} else {
node.meta = `title="${node.lang}"`;
node.meta = `title="${formattedTitle}"`;
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions website/architecture/bundled-hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ To implement this on Android, we've added a new build inside the `/ReactAndroid/
You can now trigger a build of Hermes engine by invoking:

```bash
// Build a debug version of Hermes
# Build a debug version of Hermes
./gradlew :ReactAndroid:hermes-engine:assembleDebug
// Build a release version of Hermes
# Build a release version of Hermes
./gradlew :ReactAndroid:hermes-engine:assembleRelease
```

Expand All @@ -133,7 +133,7 @@ On the Gradle consumer side, we also shipped a small improvement on the consumer

However, this made this line necessary in the template:

```
```groovy
exclude group:'com.facebook.fbjni'
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ adb logcat "*:S" ReactNative:V ReactNativeJS:V YourModuleName:D

In your native module, use `NSLog` for custom logs:

```objective-c
```objectivec
NSLog(@"YourModuleName: %@", message);
```

Expand Down
12 changes: 6 additions & 6 deletions website/versioned_docs/version-0.77/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ React Native provides the [Fetch API](https://developer.mozilla.org/en-US/docs/W

In order to fetch content from an arbitrary URL, you can pass the URL to fetch:

```tsx
```ts
fetch('https://mywebsite.com/mydata.json');
```

Fetch also takes an optional second argument that allows you to customize the HTTP request. You may want to specify additional headers, or make a POST request:

```tsx
```ts
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
Expand All @@ -43,7 +43,7 @@ The above examples show how you can make a request. In many cases, you will want

Networking is an inherently asynchronous operation. Fetch method will return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that makes it straightforward to write code that works in an asynchronous manner:

```tsx
```ts
const getMoviesFromApi = () => {
return fetch('https://reactnative.dev/movies.json')
.then(response => response.json())
Expand All @@ -58,7 +58,7 @@ const getMoviesFromApi = () => {

You can also use the `async` / `await` syntax in a React Native app:

```tsx
```ts
const getMoviesFromApiAsync = async () => {
try {
const response = await fetch(
Expand Down Expand Up @@ -189,7 +189,7 @@ export default App;

The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is built into React Native. This means that you can use third party libraries such as [frisbee](https://github.com/niftylettuce/frisbee) or [axios](https://github.com/axios/axios) that depend on it, or you can use the XMLHttpRequest API directly if you prefer.

```tsx
```ts
const request = new XMLHttpRequest();
request.onreadystatechange = e => {
if (request.readyState !== 4) {
Expand All @@ -213,7 +213,7 @@ request.send();

React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.

```tsx
```ts
const ws = new WebSocket('ws://host.com/path');

ws.onopen = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Now, we need to implement the `validateAddress` function in C++. First, we need

2. Open the `shared/NativeSampleModule.cpp` file and add the function implementation

```c++ title="NativeSampleModule.cpp (validateAddress implementation)"
```cpp title="NativeSampleModule.cpp (validateAddress implementation)"
bool NativeSampleModule::validateAddress(jsi::Runtime &rt, jsi::Object input) {
std::string street = input.getProperty(rt, "street").asString(rt).utf8(rt);
int32_t number = input.getProperty(rt, "num").asNumber();
Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-0.77/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ One reason why well-built native apps feel so smooth is by avoiding expensive op

Applications can schedule tasks to run after interactions with the following:

```tsx
```ts
InteractionManager.runAfterInteractions(() => {
// ...long-running synchronous task...
});
Expand All @@ -45,7 +45,7 @@ The touch handling system considers one or more active touches to be an 'interac

InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:

```tsx
```ts
const handle = InteractionManager.createInteractionHandle();
// run animation... (`runAfterInteractions` tasks are queued)
// later, on animation completion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ adb logcat "*:S" ReactNative:V ReactNativeJS:V YourModuleName:D

In your native module, use `NSLog` for custom logs:

```objective-c
```objectivec
NSLog(@"YourModuleName: %@", message);
```

Expand Down
12 changes: 6 additions & 6 deletions website/versioned_docs/version-0.78/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ React Native provides the [Fetch API](https://developer.mozilla.org/en-US/docs/W

In order to fetch content from an arbitrary URL, you can pass the URL to fetch:

```tsx
```ts
fetch('https://mywebsite.com/mydata.json');
```

Fetch also takes an optional second argument that allows you to customize the HTTP request. You may want to specify additional headers, or make a POST request:

```tsx
```ts
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
Expand All @@ -43,7 +43,7 @@ The above examples show how you can make a request. In many cases, you will want

Networking is an inherently asynchronous operation. Fetch method will return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that makes it straightforward to write code that works in an asynchronous manner:

```tsx
```ts
const getMoviesFromApi = () => {
return fetch('https://reactnative.dev/movies.json')
.then(response => response.json())
Expand All @@ -58,7 +58,7 @@ const getMoviesFromApi = () => {

You can also use the `async` / `await` syntax in a React Native app:

```tsx
```ts
const getMoviesFromApiAsync = async () => {
try {
const response = await fetch(
Expand Down Expand Up @@ -189,7 +189,7 @@ export default App;

The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is built into React Native. This means that you can use third party libraries such as [frisbee](https://github.com/niftylettuce/frisbee) or [axios](https://github.com/axios/axios) that depend on it, or you can use the XMLHttpRequest API directly if you prefer.

```tsx
```ts
const request = new XMLHttpRequest();
request.onreadystatechange = e => {
if (request.readyState !== 4) {
Expand All @@ -213,7 +213,7 @@ request.send();

React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.

```tsx
```ts
const ws = new WebSocket('ws://host.com/path');

ws.onopen = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Now, we need to implement the `validateAddress` function in C++. First, we need

2. Open the `shared/NativeSampleModule.cpp` file and add the function implementation

```c++ title="NativeSampleModule.cpp (validateAddress implementation)"
```cpp title="NativeSampleModule.cpp (validateAddress implementation)"
bool NativeSampleModule::validateAddress(jsi::Runtime &rt, jsi::Object input) {
std::string street = input.getProperty(rt, "street").asString(rt).utf8(rt);
int32_t number = input.getProperty(rt, "num").asNumber();
Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-0.78/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ One reason why well-built native apps feel so smooth is by avoiding expensive op

Applications can schedule tasks to run after interactions with the following:

```tsx
```ts
InteractionManager.runAfterInteractions(() => {
// ...long-running synchronous task...
});
Expand All @@ -45,7 +45,7 @@ The touch handling system considers one or more active touches to be an 'interac

InteractionManager also allows applications to register animations by creating an interaction 'handle' on animation start, and clearing it upon completion:

```tsx
```ts
const handle = InteractionManager.createInteractionHandle();
// run animation... (`runAfterInteractions` tasks are queued)
// later, on animation completion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ adb logcat "*:S" ReactNative:V ReactNativeJS:V YourModuleName:D

In your native module, use `NSLog` for custom logs:

```objective-c
```objectivec
NSLog(@"YourModuleName: %@", message);
```

Expand Down
12 changes: 6 additions & 6 deletions website/versioned_docs/version-0.79/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ React Native provides the [Fetch API](https://developer.mozilla.org/en-US/docs/W

In order to fetch content from an arbitrary URL, you can pass the URL to fetch:

```tsx
```ts
fetch('https://mywebsite.com/mydata.json');
```

Fetch also takes an optional second argument that allows you to customize the HTTP request. You may want to specify additional headers, or make a POST request:

```tsx
```ts
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
Expand All @@ -43,7 +43,7 @@ The above examples show how you can make a request. In many cases, you will want

Networking is an inherently asynchronous operation. Fetch method will return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that makes it straightforward to write code that works in an asynchronous manner:

```tsx
```ts
const getMoviesFromApi = () => {
return fetch('https://reactnative.dev/movies.json')
.then(response => response.json())
Expand All @@ -58,7 +58,7 @@ const getMoviesFromApi = () => {

You can also use the `async` / `await` syntax in a React Native app:

```tsx
```ts
const getMoviesFromApiAsync = async () => {
try {
const response = await fetch(
Expand Down Expand Up @@ -189,7 +189,7 @@ export default App;

The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) is built into React Native. This means that you can use third party libraries such as [frisbee](https://github.com/niftylettuce/frisbee) or [axios](https://github.com/axios/axios) that depend on it, or you can use the XMLHttpRequest API directly if you prefer.

```tsx
```ts
const request = new XMLHttpRequest();
request.onreadystatechange = e => {
if (request.readyState !== 4) {
Expand All @@ -213,7 +213,7 @@ request.send();

React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.

```tsx
```ts
const ws = new WebSocket('ws://host.com/path');

ws.onopen = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Now, we need to implement the `validateAddress` function in C++. First, we need

2. Open the `shared/NativeSampleModule.cpp` file and add the function implementation

```c++ title="NativeSampleModule.cpp (validateAddress implementation)"
```cpp title="NativeSampleModule.cpp (validateAddress implementation)"
bool NativeSampleModule::validateAddress(jsi::Runtime &rt, jsi::Object input) {
std::string street = input.getProperty(rt, "street").asString(rt).utf8(rt);
int32_t number = input.getProperty(rt, "num").asNumber();
Expand Down
Loading