npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kabeerhaseja-react-native-essentials

v1.0.0

Published

A collection of versatile and easy-to-use React Native components to enhance your mobile app development experience.

Downloads

3

Readme

Introduction

Introduction This is a custom hook for scrolling to the first error in a form built with Formik, a popular library for handling forms in React. The hook makes it possible to automatically scroll to the first form field with an error, improving the user experience by directing their attention to the issue and making it easier to correct.

Installation

Installation To install this hook, simply copy the code in the useFormScrollToError function and paste it in your React project. You can then import it into the component where you want to use it.

System Requirements

  • Node and npm installed
  • MacOS, Windows and Linux are supported

Installation

installation

  1. To install, run:
    npm i kabeerhaseja-react-native-essentials

#Usage The hook provides two functions: addPosition and scrollToError.

  1. Load the module in your component
 const {addPosition, scrollToError} = useFormScrollToError();

The addPosition function takes two parameters: position and key. position is the position of the form field in the scroll view, and key is the formikKey that corresponds to the field in the Formik form. This function should be called for each form field, and the position and key values should be passed as arguments.

The scrollToError function takes two parameters: formikRef and scrollViewRef. formikRef is a reference to the Formik form, and scrollViewRef is a reference to the scroll view that contains the form fields. This function should be called when the form is submitted, and it will automatically scroll to the first form field with an error.

Here's an example of how you might use this hook in a React component

import React, {useRef} from 'react';
import {useFormScrollToError} from 'kabeerhaseja-react-native-essentials';

function MyForm() {
  const formikRef = useRef(null);
  const scrollViewRef = useRef(null);
  const {addPosition, scrollToError} = useFormScrollToError();

  const handleSubmit = () => {
    scrollToError(formikRef, scrollViewRef);
  };

  return (
    <ScrollView ref={scrollViewRef}>
      <Formik
        ref={formikRef}
        onSubmit={handleSubmit}
      >
        {({handleSubmit}) => (
          <View>
            <TextInput
              onLayout={(event) => {
                addPosition(event.nativeEvent.layout.y, 'email');
              }}
            />
            <TextInput
              onLayout={(event) => {
                addPosition(event.nativeEvent.layout.y, 'password');
              }}
            />
            <Button onPress={handleSubmit} />
          </View>
        )}
      </Formik>
    </ScrollView>
  );
}

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you find a bug or would like to request a new feature, just open an issue. Your contributions are always welcome!

License

Distributed under the ISC License.

Contact

Kabeer Haseja [email protected]