# react-native-inviewport

> Detect if component is in device viewport

Latest version **1.1.0** (published 2016-02-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-inviewport
pnpm add react-native-inviewport
yarn add react-native-inviewport
bun add react-native-inviewport
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2016-02-15 |
| First published | 2016-02-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yamill Vallecillo |
| Maintainers | yamill |
| Keywords | react-component, react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-inviewport
- Repository: https://github.com/yamill/react-native-inviewport
- Homepage: https://github.com/yamill/react-native-inviewport#readme
- Issues: https://github.com/yamill/react-native-inviewport/issues
- npm.io page: https://npm.io/package/react-native-inviewport

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2016-02-15
- 1.0.0 — 2016-02-15

## README

# react-native-inviewport
Detect if component is in device viewport.
I based this off: https://github.com/joshwnj/react-visibility-sensor with some slight modifications.

<H2>Install</H2>

```sudo npm react-native-inviewport@latest --save```

<H2>Example Usage</H2>

Assuming you already setup your component, here's a quick example.

```
checkVisible(isVisible){
    if(isVisible){
      if(!this.state.visible){
        this.setState({visible: true});
      }
    }else{
      if(this.state.visible){
        this.setState({visible: false});
      }
    }
}

render() {
  return (
  <ScrollView style={{flex: 1}}>
    <InViewPort onChange={this.checkVisible}>
      <View style={{flex: 1, height: 200, backgroundColor: 'blue'}}>
        <Text style={{color: 'white'}}>View is visible? {this.state.visible}</Text>
      </View>
    </InViewPort>

    <InViewPort onChange={this.checkVisible}>
      <View style={{flex: 1, height: 200, backgroundColor: 'green'}}>
        <Text style={{color: 'white'}}>View is visible? {this.state.visible}</Text>
      </View>
    </InViewPort>

    <InViewPort onChange={this.checkVisible}>
      <View style={{flex: 1, height: 200, backgroundColor: 'red'}}>
        <Text style={{color: 'white'}}>View is visible? {this.state.visible}</Text>
      </View>
    </InViewPort>

    <InViewPort onChange={this.checkVisible}>
      <View style={{flex: 1, height: 200, backgroundColor: 'orange'}}>
        <Text style={{color: 'white'}}>View is visible? {this.state.visible}</Text>
      </View>
    </InViewPort>

    <InViewPort onChange={this.checkVisible}>
      <View style={{flex: 1, height: 200}}>
        <Text>View is visible? {this.state.visible}</Text>
      </View>
    </InViewPort>
  </ScrollView>
  );
}
```

---
_Source: https://npm.io/package/react-native-inviewport · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
