
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
react-hooks-combine
Advanced tools
React hooks powered, recompose like utility belt for ladies and gentlemen.
Hooks powered, recompose like utility belt for ladies and gentlemen.
React Hooks Combine (RHC) is a simple utility belt to help you split up logic for your components between container (smart) part and dummy component (view) part. It helps you to create only one HOC effortlessly with custom hook which combines all listed HOOKS (all in one).
It has API Design similar to Recompose.
The documentation is divided into several sections:
You can improve it by sending pull requests to this repository.
Prerequisites:
Install (choose preferable way)
yarn add react-hooks-combine
npm install react-hooks-combine
Then...
// component.jsx
import React from 'react'
export const UserPageComponent = ({ loading, userData, onSubmit, onCancel }) => (
<div>
<h2>User Form</h2>
<ContentLoadIndicator loading={loading}>
{
() => (
<UserForm
initialValues={userData}
onSubmit={onSubmit}
onCancel={onCancel} />
)
}
</ContentLoadIndicator>
</div>
)
// container.js (withAsyncEffect + withCallbacks)
import { combine, withAsyncEffect, withCallbacks } from 'react-hooks-combine'
import { UserPageComponent } from './component'
export default combine(
withAsyncEffect({
deps: ['userId'], // will request again if user id is changed
dataName: 'userData', // 'data' by default
asyncAction: (_state, ownProps) => ownProps.userService.load(ownProps.userId),
}),
withCallbacks({
onSubmit: (state, props) => async (formData) => {
const { userData } = state
const { userService } = props
await userService.save({ ...userData, ...formData})
...
},
onCancel: () => () => {
...
}
}, ['userData'])
)(UserPageComponent)
OR
// component.jsx
import React from 'react'
export const CounterComponent = ({ count, onPlus, onMinus }) => (
<div>
<strong>Active: {count}</strong>
<button type="button" onClick={onPlus}>+</button>
<button type="button" onClick={onMinus}>-</button>
</div>
)
// container.js (withReducer + withCallbacks)
import { combine, withReducer, withCallbacks } from 'react-hooks-combine'
import { CounterComponent } from './component'
const INC = 'INC'
const DEC = 'DEC'
const reducer = (count, action) => {
switch(action.type) {
case INC: return count + 1
case DEC: return count - 1
default: return count
}
}
export default combine(
withReducer({
reducer,
stateName: counterState,
initialState: 0,
}),
withCallbacks({
onPlus: ({ counterState, dispatch }, _props) => () => {
dispatch({ type: INC })
},
onMinus: ({ counterState, dispatch }, _props) => () => {
dispatch({ type: DEC })
}
}, ['counterState']), // <- deps for useCallback (CHECK API TO LEARN MORE)
)
OR
// container.js (withState + withCallbacks)
import { combine, withState, withCallbacks } from 'react-hooks-combine'
import { CounterComponent } from './component'
export default combine(
withState('count', 'setCount', 0),
withCallbacks({
onPlus: ({ count, setCount }, _props) => () => {
setCount(count + 1)
},
onMinus: ({ setCount }, _props) => () => {
setCount(count => count - 1) // function could be used
}
}, ['count']), // <- deps for useCallback (CHECK API TO LEARN MORE)
)
OR WHICHEVER YOU LIKE...
1.3.1
FAQs
React hooks powered, recompose like utility belt for ladies and gentlemen.
We found that react-hooks-combine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.