
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-easy-redux
Advanced tools
English | 中文版
A plugin that simply encapsulates redux and redux-saga. It can be used directly for React 、React-Native
This package depend on redux、redux-saga 、react-redux,So you no need install them additionally !!!!
Easier integration of redux, redux-saga. if you install this package,You don't need to install redux、redux-saga、react-redux additionally.
Automatically define a loading variable in the redux state when you trigger a effect function. Support for custom Plugin.
redux + redux-saga directly is not friendly to novices. Especially redux-saga, many novices are confused about it.
It inspired by dva.js, Why not use dva.js directly ?
Because it is too large, contains many features that are not needed for small and medium projects, and cannot be used directly in React-Native.
npm i react-easy-redux --save
import { Provider, getStore,connect } from 'react-easy-redux';
const model = {
namespace:'test',
state:{
msg:'hello,world'
},
effects:{
*fetch(payload,{call,put}) {
const response = yield call(fetchApi,payload);
yield put({
type: 'save',
payload: {
msg:response
}
})
}
},
reducers:{
save(state, action) {
return {
...state,
...action.payload
};
},
}
};
// init store
const store = getStore([model]);
export default class App extends React.Component {
render: function() {
return (
<Provider store={store}>
<div>hello,world</div>
</Provider>
)
}
}
// connect Component
const Test = (props) => {
return (
<div>{props.msg}</div>
)
}
const mapStateToProps = ({test}) => ({
msg: test.msg
})
export const ConnectTest = connect(Test,mapStateToProps);
| propName | type | required | desc |
|---|---|---|---|
| namespace | string | true | The name of the module that was eventually injected into the reducer |
| state | object | true | State injected into the corresponding reducer module |
| effects | object | false | Effects injected into redux-saga, you can use effects methods like call、 put and so on... |
| reducers | object | false | Reducer calculation method in redux |
The method for injecting react components into redux is simplified on the basis of react-redux, and it automatically injects dispatch methods into components.
const Test = props => {
return <div>{props.msg}</div>;
};
const mapStateToProps = ({ test }) => ({
msg: test.msg
});
export const ConnectTest = connect(Test, mapStateToProps);
The component after connect will have methods to trigger the corresponding effects methods. Returns a Promise. The triggered effects method will trigger the corresponding loading = true before use, and loading = false after execution.
this.props.dispatch({
type: 'namespace/effectFunctionName',
payload: {
a: 1,
b: 1,
catchSelf: false
}
});
Parameters of the dispatch method
| name | type | required | desc |
|---|---|---|---|
| catchSelf | boolean | false | Defaults false,If set to true, the exception of the triggered effect method will be thrown, and the promise returned by dispatch needs to catch itself |
Comes with a loading plugin. Each time the effect method is triggered, a loading variable is automatically generated in the state of redux for loading in exec asynchronous method.
const Test = props => {
useEffect(() => {
props.dispatch({
type: 'test/aFun'
});
});
return <div>{props.testLoading}</div>;
};
const mapStateToProps = ({ test,loading }) => ({
msg: test.msg,
testLoading:loading['test/aFun']
});
export const ConnectTest = connect(Test, mapStateToProps);
No
Welcome PR!!!! The first release of the npm package must have many shortcomings.
Create By daizq
FAQs
一个将redux redux-saga做了简易封装的轮子
The npm package react-easy-redux receives a total of 11 weekly downloads. As such, react-easy-redux popularity was classified as not popular.
We found that react-easy-redux 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.