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

redux-component

v0.3.0

Published

Create stateful React Component using goodness from redux

Downloads

6

Readme

redux-component

Create stateful React Component using goodness from redux

Version Travis CI Quality Coverage Dependencies Gitter

Quick start: Say Hi

The form component that reads name and email from the user and submit the form to the API server.

import { Componentize } from "redux-component";

const createComponent = Componentize(/* ... */);

const Component = createComponent(function SayHi (props, state, actions) {
  return (
    <form onSubmit={e => actions.submitForm(props, e)}>
      {renderUsername(state.usernameLoading, props.userId, state.username)}
      {renderError(state.error)}
      <input type="text" value={state.formValues.name} onChange={e => actions.textChanged(`name`, e)} />
      <input type="email" value={state.formValues.email} onChange={e => actions.textChanged(`email`, e)} />
      <button type="submit">Hi</button>
    </form>
  );
});

This basically covers everything for creating a stateful React component.

Documentation

See the full list of API.

Usage

redux-component requires React 0.13 or later.

npm install --save redux-component

All functions are available on the top-level export.

import { Componentize } from "redux-component";

Initiative

React 0.14 introduces stateless function components. However, what if I want to use pure functions to create stateful React components?

That's what redux-component does.

Manage a component's local state using a local redux store.

A isolated redux store is created for each React component instance. It has nothing to do with your global flux architecture. There are several goodness for this approach:

  • Express component state transition in a single reducer function
  • Event callbacks in redux actions are clean and easy to reason about
  • You build pure functions all the way: render, actions and reducer
  • No more this.setState() touched in your code
  • Easy to test React component implements

See the complete example in the examples/gh-pages folder and demo hosted on GitHub.

Contributing

devDependency Status

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request