/origen

A zero dependency, React utility library, filled with useful hooks to make your React experience even better.

Primary LanguageJavaScriptMIT LicenseMIT

ORIGEN

npm GitHub license

A zero dependency, React utility library, filled with useful hooks to make your React experience even better.

useToggle

For maintaining the value of a boolean and being able to toggle it's value between true and false;

import { useToggle } from 'origen';

export default function App() {
  const [value, toggle] = useToggle(false);

  return (
    <div>
      <h1>My value is: {value}</h1>
      <button onClick={toggle}>Toggle</button>
    </div>
  );
}

useMousePosition

For getting the current x and y coordinates of the mouse cursor.

import { useMousePosition } from 'origen';

export default function App() {
  const mousePosition = useMousePosition();

  return (
    <div>
      <h1>Width: {mousePosition.x}</h1>
      <h1>Height: {mousePosition.y}</h1>   
    </div>
  );
}

useWindowDimensions

For getting the current width and height values of the window.

import { useWindowDimensions } from 'origen';

export default function App() {
  const dimensions = useWindowDimensions();

  return (
    <div>
      <h1>Width: {dimensions.width}</h1>
      <h1>Height: {dimensions.height}</h1>      
    </div>
  );
}

License

ORIGEN is MIT licensed.