functions.js 374 B

1234567891011121314
  1. import { useState } from "react";
  2. /*
  3. Executes before Render
  4. */
  5. export const useConstructor = (callBack = () => {}) => {
  6. const [hasBeenCalled, setHasBeenCalled] = useState(false);
  7. if (hasBeenCalled) return;
  8. callBack();
  9. setHasBeenCalled(true);
  10. }
  11. export const capitalize = (str) => str.charAt(0).toUpperCase() + str.substring(1,str.length).toLowerCase()