> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Interface: Lynx

APIs under `lynx` global variable that added by ReactLynx.

## Example

```ts
lynx.registerDataProcessors(...);
lynx.querySelector(...);
lynx.querySelectorAll(...);
```

## Properties

### registerDataProcessors

> **registerDataProcessors**: (`dataProcessorDefinition?`: [`DataProcessorDefinition`](/next/api/react/Types/DataProcessorDefinition.md)) => `void`

Register DataProcessors. You MUST call this before `root.render()`.

#### Parameters

| Parameter                  | Type                                                                          |
| -------------------------- | ----------------------------------------------------------------------------- |
| `dataProcessorDefinition?` | [`DataProcessorDefinition`](/next/api/react/Types/DataProcessorDefinition.md) |

#### Returns

`void`

#### Examples

You MUST call `lynx.registerDataProcessors` before calling `root.render()`.

```ts
import { root } from "@lynx-js/react"

// You MUST call this before `root.render()`
lynx.registerDataProcessors({
  defaultDataProcessor: () => {...} // default DataProcessor
  dataProcessors: {
    getScreenMetricsOverride: () => {...} // named DataProcessor
  }
})

root.render(<App/>);
```

If you have a class component with `static defaultDataProcessor`
or `static dataProcessors`, you can use it to register DataProcessors.

```ts
import { root, Component } from "@lynx-js/react"

class App extends Component {
  static defaultDataProcessor() {
     ...
  }

  static dataProcessors = {
    getScreenMetricsOverride() {
      ...
    }
  }
}

lynx.registerDataProcessors(App); // You can pass `App` because it has the required shape
root.render(<App/>);
```

For developers who want fully typed `defaultDataProcessor`,
they can achieve it by extends interface `InitDataRaw` and `InitData`.

```ts
import { root } from "@lynx-js/react"

interface ExistingInterface {
  somePropertyFromExistingInterface: number
}

declare module '@lynx-js/react' {
  interface InitDataRaw extends ExistingInterface {
    someAnotherCustomProperty: string
  }
}

lynx.registerDataProcessors({
  defaultDataProcessor: (initDataRaw) => {
    initDataRaw.somePropertyFromExistingInterface // will be typed
  }
})

```

For developers who want fully typed `defaultDataProcessor`,
they can achieve it by extends interface `InitDataRaw` and `InitData`.

```ts
import { useInitData } from "@lynx-js/react"

interface AnotherExistingInterface {
  someAnotherPropertyFromExistingInterface: number
}

declare module '@lynx-js/react' {
  interface InitData extends AnotherExistingInterface {
    someCustomProperty: string
  }
}

lynx.registerDataProcessors({
  defaultDataProcessor: () => {
    return {
      someCustomProperty: 'value', // will be typed
      someAnotherPropertyFromExistingInterface: 1, // will be typed
    }
  }
})

function App() {
  const initData = useInitData();

  initData.someCustomProperty // will be typed
  initData.someAnotherPropertyFromExistingInterface // will be typed
}

```

***

### triggerGlobalEventFromLepus

> **triggerGlobalEventFromLepus**: (`eventName`: `string`, `params`: `any`) => `void`

An alias of `lynx.getJSModule("GlobalEventEmitter").trigger(eventName, params)` only in Lepus

#### Parameters

| Parameter   | Type     |
| ----------- | -------- |
| `eventName` | `string` |
| `params`    | `any`    |

#### Returns

`void`
