How to use the reactfire.useDatabase function in reactfire

To help you get started, we’ve selected a few reactfire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FirebaseExtended / reactfire / sample / src / RealtimeDatabase.js View on Github external
const List = props => {
  const database = useDatabase();
  const ref = database().ref('animals');
  const changes = useDatabaseList(ref);
  const addNewAnimal = commonName => {
    const newAnimalRef = ref.push();
    return newAnimalRef.set({
      commonName
    });
  };

  const removeAnimal = id => ref.child(id).remove();

  return (
    <>
      
      <ul>
        {changes.map(({ snapshot }) =&gt; (</ul>