[](https://badge.fury.io/js/react-native-scroll-to-element)
npm install react-native-scroll-to-element
Focus View elements within the ScrollView. Similar to DOMElement.scrollIntoView() for web. Compatible with Expo
- React context-api
- React hooks
- Mobx@6
This library allows to get focus of an element, any direct or indirect child element of ScrollView.

I created based on react-native-scroll-into-view (https://github.com/slorber/react-native-scroll-into-view), I made this component with less code and with new features of react/react-native.
```
npm install react-native-scroll-to-element`
or`
yarn add react-native-scroll-to-element
1. Replace ScrollView component to SpecialScrollView from react-native-scroll-into-view
2. On the element you want to focus on, wrap it with SpecialView component
3. You can pass "focused" prop (declarative mode) or call "focus" method (imperative mode)
- Declarative
`tsx
import React from 'react';
import { Text, View } from 'react-native';
import { SpecialScrollView, SpecialView } from 'react-native-scroll-to-element';
export default function () {
return (
height: 400,
backgroundColor: 'red'
}}
/>
height: 50,
backgroundColor: 'blue'
}}
focused
>
color: 'white',
fontSize: 20,
padding: 10
}}
>
Focus here
height: 800,
backgroundColor: 'green'
}}
/>
);
}
`
- Imperative:
`tsx
import React, { useRef } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { SpecialScrollView, SpecialView } from 'react-native-scroll-to-element';
export default function () {
const viewRef = useRef()
return (
height: 400,
backgroundColor: 'red'
}}
/>
height: 50,
backgroundColor: 'blue'
}}
ref={viewRef}
>
>
color: 'white',
fontSize: 20,
padding: 10
}}
>
Focus here
height: 800,
backgroundColor: 'green'
}}
/>
);
}
``
Props of SpecialScrollView is the same of ScrollView. The same way, SpecialView receives props of View component