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

react-firebase-schema-form

v1.1.1

Published

A tool to create a simple form (that can be styled) to allow for schema object basic validation and data entry into a Firebase database (with auth user creation optional)

Downloads

26

Readme

react-firebase-schema-form

A tool to create a simple form (that can be styled) to allow for schema object basic validation and data entry into a Firebase database (with auth user creation optional)

Overview

This database tool can be used strictly for entering data into your Firebase database or can be used for client side forms with a little bit of extra styling.

Install package:

Install react-firebase-schema-form npm module:

$ npm install --save react-firebase-schema-form

Note: You will need the firebase npm package installed and intialize in your app for the DBFormTool to use. Code example for initializing firebase at bottom of this page.

To use in your code:

ES6 -

import DBFormTool from 'react-firebase-schema-form';

To use form first create a schema to use:

export const exampleUser = {
  firstName_r: "",
  lastName_r: "",
  email_e_r: "",
  password_r: "",
  phoneNumber: "",
  bio: {
    gradeLevel_r: "",
    hours: "",
    text: ""
  },
  children_i: {},
  activeChats_i: {},
  inactiveChats_i: {},
  activeMessages_i: {},
  inactiveMessages_i: {},
  createdAt_i: "",
  askAgain_i: "true",
  userRights_key_i: "****************"
};

If you notice you have some validation options. Use the following to provide basic html validation to fields:

  • '_e' will check for a valid email

  • '_i' will ignore this field in the form, but still allow for information to be included in the database push

  • '_r' will require this field to be entered when filling out the form.

    *The current method of this tool requires that the '_r' be the last validation item in a chain, but you can chain them along for example look at the email property in the schema object.

email_e_r: "",

this will both verify it is an email as well as require the field to be entered.

Next, we can now use the tool:

We can call our component using the tag

<DBFormTool
     branch="users/examplebranch"
     inSchema={exampleUser}
     createUser= true
     modalShutFunct={() => this.toggleModal()}
     title="Enter User Information"
/>

the modal shut function is not required to be passed in, but we use this client side with some styling and have this form render in a modal. If you would like to incorporate it that way I have left the functionality intact.

  • branch - this is the branch of the Firebase database you would like the new data pushed to
  • inSchema - this is the schema that we created earlier called "exampleUser"
  • createUser - a bool passed in to let the tool know if you want an authentication user created along with the push to the database. This will only create an authentication user by email and password.
  • modalShutFunct - function to shut the modal or other display showing form.
  • title - the title for the form to show

Note: firebase initialization required - You must have the firebase npm package installed and authorized. For further information on this please see the firebase npm package

Styling

I have included className tags in the JSX elements for styling purposes if you would like to style the form.

  • dbtool-unorderedList - the unordered list.
  • dbtool-nestedHeader - any nested object headers -- in the example 'bio' would use this className.
  • dbtool-listItemWithInput - the list item, or label for input fields
  • dbtool-input - input fields for data entry
  • dbtool-footer - any footer styling for the section containing the submit button
  • dbtool-button - submit button styling

Firebase initialization code

var config = {...};

// firebase initialization
const firebaseObj = firebase.initializeApp(config);