Coder Social home page Coder Social logo

laveen777 / hocs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deepsweet/hocs

0.0 0.0 0.0 1.89 MB

:bento: Higher-Order Components for React

Home Page: https://github.com/deepsweet/hocs/issues/31

License: MIT License

JavaScript 99.73% HTML 0.27%

hocs's Introduction

ci coverage

A collection of Higher-Order Components for React, especially useful with Recompose.

A Higher-Order Component is a function that takes a component and returns a new component.

Packages

Universal

🚱 omit-props

Helps to omit unnecessary context, state setters or anything else you don't want to propagate with {...spread}.

♻️ with-lifecycle

Provides a handy way to use some of React Component Lifecycle methods.

Helps to debounce handlers like onChange.

Helps to throttle handlers like onChange.

Provides safe versions of setTimeout, setInterval, requestAnimationFrame and requestIdleCallback which will be cleared/cancelled automatically before component is unmounted.

Invokes a callback on prop change, useful to decouple side effects like onChange handler in a declarative way.

Invokes a callback on prop change while condition is true, useful to decouple side effects like onChange handler in a declarative way and control loops.

Invokes a callback once condition is true (while previous check was false), useful to decouple side effects like onSuccess or onError handlers in a declarative way.

πŸ” with-log

Injects console.log with props or any custom message into render.

πŸ” with-debugger

Injects debugger into render.

Browser

Dynamically map CSS Media Queries matches to boolean props using window.matchMedia() (Can I use?).

Dynamically map component size and position changes to props using Resize Observer API (Can I use? πŸ™ˆ).

Dynamically map visibility of a component to boolean props using Intersection Observer API (Can I use?).

Dynamically map page visibility status to props using Page Visibility API (Can I use?).

Dynamically map online/offline status to props using navigator.onLine (Can I use?).

Decouples e.preventDefault() side effect from handlers like form submitting or clicking a link.

React Native

Dynamically map View layout dimensions to props using onLayout() handler.

…and more to come

You can follow me on Twitter for updates.

Development

  1. Create a new folder in packages/, let's say with-foo.
  2. See package.json in already existing packages and create new with-foo/package.json.
  3. Put source code in with-foo/src/, it will be transpiled and bundled into with-foo/dist/, with-foo/lib/ and with-foo/es/.
  4. Put tests written with Jest in with-foo/test/.
  5. Put demo in with-foo/demo/, it will be rendered and wrapped with HMR.

Available commands using Start:

yarn start build <package>
yarn start demo <package>
yarn start test
yarn start testWatch
yarn start lint

hocs's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.