
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
react-redux-resolve
Advanced tools
Experimental library to universally resolve your component's initial data.
Experimental library to universally resolve your component's initial data. Per component you can specify a resolver. On the client side, the resolver is executed in componentDidMount() and on the server-side once you call waitForResolves(renderProps, store). This makes server-side rendering easy to implement!
import { resolve } from 'react-redux-resolve';
@resolve(({ dispatch }) => dispatch(fetchSandwich()))
class MyComponent extends Component {
render() {
const { sandwich } = this.props;
return (
<Sandwich sandwich={sandwich} />
);
}
}
Where fetchSandwich() is something like the below (please note the example doesn't handle errors). This requires the redux-thunk middleware:
function fetchSandwich() {
return (dispatch) => {
dispatch({
type: 'FETCH_SANDWICH_STARTED',
sandwich: sandwich
});
return fetch('http://example.com/api/sandwich')
.then((response) => response.json())
.then((sandwich) => {
dispatch({
type: 'FETCH_SANDWICH_SUCCEEDED',
sandwich: sandwich
});
});
};
}
Now, say you're rendering your app on the server, you can easily access the @resolve(). You can do this by accessing .resolves on the components. We've created a helper method called waitForResolves(renderProps, store) to do this:
import { waitForResolves } from 'react-redux-resolve';
// Set up your server-side rendering like you normally would do.
match({ routes, location }, (error, redirectLocation, renderProps) => {
if (redirectLocation) {
// TODO: 3xx
}
else if (error) {
// TODO: handle error
}
else if (!renderProps) {
// TODO: 404
}
else {
// Here we call the helper method `waitForResolves`. It calls
// all your components's resolve methods and returns a promise
// which is resolved once all
waitForResolves(renderProps, store)
.then(() => {
// TODO: render html
});
}
});
@resolve(({ dispatch }) => dispatch(..))
class MyComponent extends Component { };
resolver receives an object with the following keys as argument:
dispatch: the store's dispatch functiongetState: the store's getState functionhistory: the history object from your routerparams: the params object from the routequery: the query object from the routePlease note resolve() returns a new component wrapped with the target component, similar to connect(). To use resolve() in ES5, try the following:
MyComponent = resolve(function(obj) {
return obj.dispatch(..);
})(MyComponent);
FAQs
Experimental library to universally resolve your component's initial data.
We found that react-redux-resolve 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.