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

recompose-extends

v1.12.12

Published

-----

Downloads

97

Readme

Recompose Extends


build status coverage code climate npm version npm downloads

Recompose Extends is a set of utilities that extends the functionality of the Recompose library

npm install recompose-extends --save

Demo

You can see examples of the library at the following url:

https://pedrojpj.github.io/recompose-extends/

Higher-order components

removeProp()

const enhance = compose(withProps({ counter: 0 }), removeProp('counter'))
const Counter = enhance(({ counter }) =>
  <div>
    Count: {counter}
  </div>
)

Eliminates props that are not going to be used by the inferior components

waitFor()


const View = () => <div>Loaded</div>;

const loadPromise = () => new Promise(resolve => {
  setTimeout => (() => resolve(true), 3000)
})

const enhance = compose(
  withProps({ promise: loadPromise()}),
  waitFor(['promise']))
  (View)

Wait for one or more promises before rendering the component

withActions()


export default compose(
  withReducer('state', 'dispatch', reducer, initialState),
  withActions({ increment, decrement }),
  pure
)(View);

To use with the component withReducer, you can create props as curry functions that receive the dispatch and status by default. Similar to Redux's connect

withErrors()


const WithErrors = ({ example }) => <div>{example()}</div>;

export default compose(withErrors({ debug: true }), pure)(WithErrors);

Adds an error handler in the component allowing you to visualize the chain of errors in debug mode or prevent the rendering of other components from failing. Similar to the componctDidCatch of React

withModal()


export default compose(
  withState('modal', 'setModal', false),
  withModal(({ modal }) => modal, Modal, ({ setModal }) => ({
    onClose: () => setModal(false)
  })),
  pure
)(WithModal);

High order component used to render another component in portal mode next to our base component. Useful for manners or tooltips

withForm()


const Form = ({ form, updateForm, submitForm }) => (
  <form>
    <input type="text" name="name" value={form.name} onChange={updateForm} />
    <button type="submit" onClick={submitForm}>
      Send
    </button>
  </form>
);

const enhance = compose(
  withForm(
    {
      name: { value: '', required: true }
    },
    () => () => {
      console.log('form submitted');
    }
  )
)(Form);

High order component that allows to manage a form, includes validation of required fields

withRefs()


const WithRefs = ({ setRef }) => (
  <button className="btn btn-primary" ref={r => setRef('button', r)}>
    Example
  </button>
);

export default compose(
  withRefs(),
  lifecycle({
    componentDidMount() {
      console.log(this.props.getRef('button'));
    }
  }),
  pure
)(WithRefs);

High order component for easy access to React refs using recompose

withChildren()


const Component = ({ ComponentButton }) => <div>{ComponentButton}</div>;


const WithChildren = compose(
  withChildren(['button']),
)(Component);


<WithChildren><button>Example</button><div /></WithChildren>

High order component for to filter and select children, destroy the children by building a prop for each of the selected children to place them in the parent as you wish