
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-latency
Advanced tools
A packaged version of the latency widget used by Jared Palmer in his [Moving To React Suspense](https://www.youtube.com/watch?v=SCQgE4mTnjU) talk from React Conf 2018,
A packaged version of the latency widget used by Jared Palmer in his Moving To React Suspense talk from React Conf 2018,
It's useful for mocking fetch requests at different latencies to observe how your app looks in various loading statees.
The following examples are based around an app in it's default state when generated with create-react-app.
The package exports 3 named exports:
init - a function that should be called at some point in your application to instantiate the debugger widgetappWrapper - a HOC wrapper for your application/componentmockApiCall - a function to replace any fetch calls in your app that you wish to mock and add latency toappWrapper and wrap the App component with it:import React, { Component } from 'react';
import { appWrapper } from 'react-latency';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
}
export default appWrapper(App);
mockApiCall and use it in place of a fetch call:import React, { Component } from 'react';
import { appWrapper, mockAPICall } from 'react-latency';
import logo from './logo.svg';
import './App.css';
class App extends Component {
async componentDidMount() {
const result = await mockAPICall('/test', { hiphip: 'hooray' });
console.log(result);
}
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
}
export default appWrapper(App);
init and invoke the function somewhere in your application, e.g. the index.js of your create-react-app application:import React from 'react';
import ReactDOM from 'react-dom';
import { init } from 'react-latency';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
init();
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
Thanks to Jared Palmer and Dan Abramov? for the code.
FAQs
A packaged version of the latency widget used by Jared Palmer in his [Moving To React Suspense](https://www.youtube.com/watch?v=SCQgE4mTnjU) talk from React Conf 2018,
We found that react-latency 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.