
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
With yarn:
yarn add estafette
With npm:
npm install estafette
useRequest(initialValues)Hook function for fetching data. Every request will save data or validation errors and turn on/off loading.
initialValues (Object): an object with initial values
const estafette = useRequest({
loading: true,
data: { title: 'Initial title' },
errors: { title: 'This field is required' },
});
request a function which executes another callback function, stores request data, switches on/off loading and catches errorsdata stores all data from callback functionerrors catches all errors from callback functionloading stores loading stateimport React, { useEffect } from 'react';
import axios from 'axios';
import { useRequest } from 'estafette';
const App = () => {
const { request, data, loading, errors } = useRequest();
useEffect(() => {
request(axios.get('https://jsonplaceholder.typicode.com/todos/1'));
}, []);
if (loading) {
return <span>Loading ...</span>;
}
return (
<div>
<h1>Title: {data.title}</h1>
</div>
);
};
request(data, params)request(fn: Function, { concat: boolean | string }) from useRequest as the second argument accepts object params with concat which can be a boolean, it means every new data from callback will concatinate with current data. Also, it can be a string in case when necessary to concatinate just some property from object in data.import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { useList, useRequest } from 'estafette';
const App = () => {
const [page, setPage] = useState(1);
const { request, data, loading } = useRequest();
useEffect(() => {
request(axios.get('https://jsonplaceholder.typicode.com/posts'), { concat: page > 1 });
}, [page]);
const onChangePage = () => setPage(page + 1);
return (
<>
<ul>
{useList(data, (item) => (
<li>{item.title}</li>
))}
</ul>
<button onClick={onChangePage}>{!loading ? 'View more' : 'Loading'}</button>
</>
);
};
request(data, params)In the code bellow with additional parameters for request function we can switch off loading toggle and prevent errors reseting. Can be useful for seamless loading or for keeping validation errors in a form.
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { useList, useRequest } from 'estafette';
const App = () => {
const [page, setPage] = useState(1);
const { request, data, loading } = useRequest();
useEffect(() => {
request(axios.get('https://jsonplaceholder.typicode.com/posts'), { toggleLoading: false, resetErrors: false });
}, [page]);
return (
<>
<span>{errors.details}</span>
<ul>
{useList(data, (item) => (
<li>{item.title}</li>
))}
</ul>
</>
);
};
useList(data, renderItem)Hook function for rendering list of data. Every item will be memoized and updated only when their data changes.
list (Array): Datarender (Function): Render function which will be called for every item in list<ul>
{useList(['a', 'b', 'c', 'd'], (item, i) => (
<li>
{i + 1}. {item}
</li>
))}
</ul>
You can get the error Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return statement. if you show or hide HOOK after first rendering, for this case you have to save into a variable, like this:
const renderList = useList(['a', 'b', 'c', 'd'], (item, i) => (
<li>
{i + 1}. {item}
</li>
));
return <ul>{renderlist}</ul>;
FAQs
Estafette helps you write code a bit faster
The npm package estafette receives a total of 51 weekly downloads. As such, estafette popularity was classified as not popular.
We found that estafette 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.