https://github.com/sergeymild/react-native-jsi-view-helpers
React Native Jsi view helpers for measure text and view.
https://github.com/sergeymild/react-native-jsi-view-helpers
jsi react-native turbomodule
Last synced: 5 months ago
JSON representation
React Native Jsi view helpers for measure text and view.
- Host: GitHub
- URL: https://github.com/sergeymild/react-native-jsi-view-helpers
- Owner: sergeymild
- License: mit
- Created: 2022-03-13T12:07:04.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-05-18T11:41:23.000Z (about 1 year ago)
- Last Synced: 2025-09-29T00:57:14.460Z (9 months ago)
- Topics: jsi, react-native, turbomodule
- Language: TypeScript
- Homepage:
- Size: 1.48 MB
- Stars: 22
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-jsi-view-helpers
React Native Jsi view helpers
## Installation
```sh
package.json
"react-native-jsi-view-helpers": "sergeymild/react-native-jsi-view-helpers#1.0.10"
yarn
npx pod-install
```
## Usage
```typescript
import { viewHelpers } from "react-native-jsi-view-helpers";
export interface MeasureParams {
text: string;
fontSize: number;
maxWidth: number;
allowFontScaling?: boolean;
usePreciseWidth?: boolean;
fontFamily?: string;
weight?: TextProps['fontWeight']
}
export interface MeasureTextResult {
height: number;
width: number;
lineCount: number;
lastLineWidth: number;
}
export interface MeasureViewResult {
height: number;
width: number;
x: number;
y: number;
}
export class viewHelpers {
static measureText(params: MeasureParams): MeasureTextResult;
static measureView(ref: React.RefObject): MeasureViewResult;
// scroll to any child in ScrollView
static scrollToChild(
params:
| {
// nativeID of scroll view
scrollNativeID: string;
// nativeID of child in scroll view (can be nested in another views)
childNativeID: string;
// offset
offset?: number;
// scroll to child end view (by default scroll to top)
scrollToEnd?: boolean;
}
| {
// ref of scroll view
scrollViewRef: React.RefObject;
childNativeID: string;
offset?: number;
scrollToEnd?: boolean;
}
)
}
```
## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT