Skip to content

deltablue-cloud/react-cosmos-stateful-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-cosmos-stateful-proxy

A stateful container for stateless react components

npm package https://www.npmjs.com/package/react-cosmos-stateful-proxy

Stateless react components are pretty common but they can be kind of hard to test by themselves when you don't have a wrapper component to hold the state.

That is where this stateful proxy comes in.

to use:

Configuration

// cosmos.proxies.js
import StatefulProxy from 'react-cosmos-stateful-proxy';

export default [
  StatefulProxy,
  // ...other proxies
]

Activation

// __fixtures__/example.js
export default {
  component: MyComponent,
  // Any function property you want controlled should be passed into controllers
  // the controllers use React's State internally and the return values will work like setState

  // for example: the onChange of this component will change the prop 'value'
  controllers: {
    onChange: value => ({ value })
  }
}

About

A stateful container for stateless react components

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%