Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-whereto
Advanced tools
Where to?
yarn add react-whereto
Make a dispatcher
// my-dispatcher.js
import { RouteDispatcher } from 'react-whereto'
async function myPromise(who) {
return Promise.resolve(1);
}
export const routeDispatcher = new RouteDispatcher()
.route('/', { strict: true, exact: true }, () => dispatch => dispatch({ type: 'MY_ACTION' }))
.route('/hello/:who', ({ params: { who } }) => myPromise(who))
.route('/world', { type: 'MY_OTHER_ACTION' });
Wrap it with whatever you like (probably a redux dispatcher)
// my-loader.js
import { dispatchLoader } from 'react-whereto'
import { createStore, applyMiddelware } from 'redux';
import thunk from 'redux-thunk';
import routeDispatcher from './my-dispatcher';
const reducer = state => state; //.. a reducer, you know
const store = createStore(reducer, {}, applyMiddelware(thunk))
const locationHandler = dispatchLoader(routeDispatcher)(store.dispatch);
locationHandler('/hello/bob').then(() => {
console.log('myPromise ran!');
});
Or let it load automatically with every route change.
// my-app.js
import React from 'react';
import { Provider } from 'react-redux';
import { DispatcherProvider } from 'react-whereto';
import { BrowserRouter, withRouter } from 'react-router-dom';
import routeDispatcher from './my-dispatcher';
const reducer = state => state; //.. a reducer, you know
const store = createStore(reducer, {}, applyMiddelware(thunk))
class NavOnLoadBase extends React.Component {
componentDidMount() {
// now the promise will load again!
this.props.history.push('/hello/bob');
}
render() {
return <div>Hi App</div>;
}
}
const NavOnLoad = withRouter(NavOnLoadBase);
const App = () => (
<BrowserRouter>
<Provider store={store}>
<DispatcherProvider store={store} dispatcher={routeDispatcher}>
<NavOnLoad />
</DispatcherProvider>
</Provider>
</Router>
);
export App;
yarn install
yarn run example
Then open your browser to http://127.0.0.1:3000
react-whereto
is free software under the MIT license.
FAQs
Where to?
We found that react-whereto 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.