Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
connect-redux-typescript
Advanced tools
It is Helper for better typescript coverage of redux connect function npm package
First, init helper function with your redux state and pass connect function
import {connectHelperInit} from 'connect-redux-typescript'
import {connect} from 'react-redux'
import {State} from './path/to/typeof/state'
export const connectHelper = connectHelperInit<State>(connect)
Use helper in every place you want to use connect function
...
import {connectHelper} from './path/to/connectHelper';
const {connect, propsGeneric} = connectHelper(
(state) => state.example,
{sayAction}
)
Pass typeof propsGeneric
to type of your React component
export class ExampleComponent extends React.Component<typeof propsGeneric> {
render() {
const {sayText, asyncMessage} = this.props
return (
<div>
You say: {sayText || 'nothing'} <hr />
<button onClick={() => sayAction(value)}> Say Hello </button>
</div>
)
}
}
Return connected component
export default connect(ExampleComponent)
If you want to pass own props to component, use this construction
interface OwnProps {
field: string
}
const {connect, propsGeneric} = connectHelper(
(state, props: OwnProps) => state.example,
{sayAction}
)
If you use async actions like redux-thunk
and you want to know what type action return, you have to use dispatch explicitly
...
return (
<div>
You say: {sayText || 'nothing'}
<hr />
<button onClick={() => this.props.dispatch(sayAction(value)).then(value => alert(value))}>
Say Hello
</button>
</div>
)
FAQs
Typings and helper for connect function of redux
We found that connect-redux-typescript 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.