
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
reduction-sauce
Advanced tools
Checkout the latest documentation on gitbook
npm i -S reduction-saucereductionReducer as one of your reducers.// app.jsx
import {reductionReducer} from 'reduction-sauce'
import { Provider, connect } from 'react-redux'
import { combineReducers, createStore } from 'redux'
import SimpleEl from './smart-components/simple-el'
const store = createStore(combineReducers({
reductionReducer,
// Other reducers
}))
ReactDOM.render(
<Provider store={store}>
<SimpleEl />
</Provider>,
document.getElementById('react-render')
)
// smart-components/simple-el.jsx
import React, { PropTypes } from 'react'
class SimpleEl extends React.Component {
render () {
// These are passed down as props from the store.
const {title, subtitle} = this.props
return (
<div>
<h1>Title: {title}</h1>
<p>{subtitle}</p>
</div>
)
}
}
SimpleEl.propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string
}
// smart-components/simple-el.jsx
import {reductionSauce} from 'reduction-sauce'
import React, { PropTypes } from 'react'
class SimpleEl extends React.Component {
render () {
// These are passed down as props from the store.
const {title, subtitle} = this.props
return (
<div>
<h1>Title: {title}</h1>
<p>{subtitle}</p>
</div>
)
}
}
SimpleEl.propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string
}
// Use reductionSauce Like connect, from react-redux, but with 1 addition option argument at the beginning.
export default reductionSauce(
{ // Options for reductionSauce, only key is supported for now.
key: 'SimpleElReducerKey' // required
},
// The following arguments are passed to connect from 'react-redux'
(state) => ({stupid: state.otherReducer.stupid}), // Map state to props, just like with redux connect
{...actionsFromElsewhere} // map actions to dispatch actions just like redux connect
// any other props get passed directly to connect
)(SimpleEl)
// smart-components/simple-el.jsx
import {reductionSauce} from 'reduction-sauce'
import React, { PropTypes } from 'react'
class SimpleEl extends React.Component {
componentWillMount() {
// use set props just like setState. This uses a shallow merge, and passes
// all keys down as props. See render()
this.props.setSauce({
title: 'Component Will Mount',
subtitle: 'The last lifecycle method was componentWillMount'
})
}
componentDidUpdate () {
// You can also replace a single key if you want.
this.props.setSauceKey('title', 'Looks like the component updated')
this.props.setSauceKey('subtitle', 'The last lifecycle method was componentDidUpdate')
}
componentWillUnMount () {
// Clear the state of this view on exit.
this.props.resetSauce()
}
render () {
// These are passed down as props from the store.
const {title, subtitle} = this.props
return (
<div>
<h1>Title: {title}</h1>
<p>{subtitle}</p>
</div>
)
}
}
SimpleEl.propTypes = {
title: PropTypes.string,
subtitle: PropTypes.string
}
export default reductionSauce(
{key: 'SimpleElReducerKey'}, // Options for reductionSauce, only key is supported for now.
(state) => ({stupid: state.otherReducer.stupid}), // Map state to props, just like with redux connect
{...actionsFromElsewhere} // map actions to dispatch actions just like redux connect
)(SimpleEl)
If you wanted to use SimpleEl multiple times, with a different key for each, add a unique props: sauceKey. This works similarly the reacts key propery.
import SimpleEl from './SimpleEl'
const simpleTextArr = [
{title: 'title 0', subtitle: 'subtitle 0'},
{title: 'title 1', subtitle: 'subtitle 1'},
{title: 'title 2', subtitle: 'subtitle 2'}
]
export default () => <ul>
{simpleTextArr.map((simpleText, index) => <li key={index}><SimpleEl sauceKey={index} {...simpleText} /></li>
</ul>
FAQs
Simple key value reducers without boilerplate
The npm package reduction-sauce receives a total of 12 weekly downloads. As such, reduction-sauce popularity was classified as not popular.
We found that reduction-sauce demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.