Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
A tiny decorator 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;
jaxDefaults.pendingKey = 'loading';
/* overwrite options for a 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.
props[abortKey]() -> undefined
Aborts all pending requests sent by the component.
props[pending] -> boolean
Returns true if any request sent by the component are pending.
props[method](...args) -> req
Exact same function signatures that jax exposes. See relevant jax code.
FAQs
A tiny decorator to manage AJAX requests in React components.
The npm package react-jax receives a total of 10 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.