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.
A tiny higher order component to manage AJAX requests in React components.
componentWillUnmount
.pending
state as a property.import React from 'react';
import { jax, jaxDefaults } from 'react-jax';
import superagent from 'superagent';
/* set global defaults */
jaxDefaults.client = superagent; // IMPORTANT
jaxDefaults.pendingKey = 'loading';
/* overwrite global options for a specific component */
@jax({ // same as defaults
methods: ['get', 'post', 'del', 'put'],
pendingKey: 'pending',
abortKey: 'abort'
})
export default class MyComponent extends React.Component {
sendRequest = () => {
this.props.get('https://example.com').end((err, res) => {
// your code
});
}
render() {
return this.props.pending ?
<button onClick={this.sendRequest}>Click Me</button> :
<button onClick={this.props.abort}>Cancel</button>;
}
}
@jax(options)
export default class Test extends React.Component {
/* your code */
}
class Test extends React.Component {
/* your code */
}
export default jax(options)(Test);
These options can be passed to the jax()
function. Or be set on the
exported jaxDefaults
object.
client
requiredmethods
defaults to ['get', 'post', 'del', 'put']
Array of jax methods to expose as properties.
pendingKey
defaults to pending
Property name to expose the pending status as.
abortKey
defaults to abort
Property name to expose the abort function as.
endEvents
defaults to ['end', 'abort']
Events emitted by the clients request object than indicate it should be cleaned up.
props[abortKey]() -> undefined
Aborts all pending requests sent by the component.
props[pendingKey] -> boolean
Returns true if any request sent by the component are pending.
props[method](...args) -> req
Exact same function signature the client
exposes.
For example, superagent will expose functions like these.
FAQs
A tiny decorator to manage AJAX requests in React components.
The npm package react-jax receives a total of 1 weekly downloads. As such, react-jax popularity was classified as not popular.
We found that react-jax 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.