
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
React data container for isomorphic applications, providing a unified and performant load & reload pattern
DISCLAIMER: THIS MODULE IS COMPLETELY WORK IN PROGRESS, AND WILL BE FOR THE NEXT FEW DAYS. IF YOU LIKE THE WORK SO FAR, KEEP AN EYE OUT, WE SHOULD BE RELEASING A STABLE VERSION IN A WEEK OR SO.
React data container for isomorphic applications, providing a unified and performant load & reload pattern.
The motivation behind redata is to create a flexible, efficient and simple solution for isomorphic react components to asynchronously load information. A few driving concepts behind redata:
$ npm install --save redata
Here's an example of how you would redata a ShoppingBag component which requires that the contents of the bag be loaded via a fetchBag() that already exists, and returns a Promise:
import React, { PureComponent, PropTypes } from 'react';
import redata from 'redata';
import fetchBag from './fetchBag';
class ShoppingBag extends PureComponent {
render() {
const { result, loading, error } = this.props;
// loading and error are provided by redata, but you can rename
// or even drop any property that you don't need in the mapper
if (error || loading) {
return null; // you could render an error message or loading respectively
}
return (
<ul>{ result.map((item) => (
<li key={ item.id }>{ item.name }</li>
)) }</ul>
);
}
}
ShoppingBag.propTypes = {
bagId: PropTypes.number.isRequired,
loading: PropTypes.bool,
error: PropTypes.instanceOf(Error),
result: PropTypes.array,
};
export default redata(
({ nextProps }) => fetchBag(nextProps.bagId), // loader
({ props, nextProps }) => props.bagId !== nextProps.bagId, // shouldReload policy
)(ShoppingBag);
redata is a Higher Order Component with the following signature:
redata(loader[, shouldReload, mapper])(WrappedComponent)
loader: The function that is responsible for loading the data. Function is invoked with ({ props, state }) and should return a Promise for the data.shouldReload (optional):
boolean.({ props, nextProps, state, nextState, data }) => false, meaning that by default the data is only loaded once, and reused until the component is unmounted. data refers to the result of the last redata.mapper (optional):
(data) => data. data is an object containing:
loading: true if the loader is still running, false otherwise.error: An instance of Error in case the loader failed, undefined otherwise.result: The result of the loader, or undefined if the loader is still running.So you're interested in understanding how redata works under the hood. That's awesome.
The motivation behind redata is already explained in the introduction, but in order to get it to work, there were a few pitfalls that we had to avoid.
In terms of the server side rendering, the way that redata discovers async dependencies in data is inspired by Apollo.
Here's a breakdown of how the whole redata flow works:
redata component is rendered for the first time.window by the server-side render, which is then accessed by the client.shouldReload function, which determines if the data is still good, or if it needs to reload.FAQs
React data container for isomorphic applications, providing a unified and performant load & reload pattern
We found that redata 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.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.