Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@exlabs/react-csv-generator
Advanced tools
Let's generate a CSV file on the frontend side. Efficiently and quickly with TypeScript support.
npm install react-csv-generator
or
yarn add react-csv-generator
Prop | Required | Description | Example |
---|---|---|---|
children | ✅ | Content of the component | "Download" or <div>Download me</div> |
fileName | ✅ | Name of the generated file | "generated-file" |
className | ⬜️ | Class name to custom CSS styling | "own-class" |
baseEndpoint | ⬜️ ✅ | URL of the endpoint. If set, you can't set items | "https://api.punkapi.com/v2/beers" |
endpointDetails | ⬜️ | Additional params for the endpoint set in baseEndpoint | { page: 1, per_page: 3 } |
items | ⬜️ ✅ | Array of data ready to generate the CSV. If set, you can't set baseEndpoint | [ { id: 1 }, { id: 2 } ] |
labels | ⬜️ | Custom labels for fields | { name: 'User name', created_at: 'Created at' } |
objectNameInResponse | ⬜️ | If endpoint will return data in some particular object, pass its name | "items" |
loader | ⬜️ | Component to replace the default loader | <MyOwnLoader /> |
errorMessage | ⬜️ | Message if something goes wrong. Default value: Something went wrong, please try again. | "Oppps, sorry!" |
noDataMessage | ⬜️ | Message if there is no data to generate the CSV file. Default value: No data to generate the file. | "Your data object is empty!" |
import React from 'react';
import CsvGenerator from '@exlabs/react-csv-generator';
const data = [{ id: 1, name: 'first' }, { id: 2, name: 'second' }];
const MyComponent = () => {
return (
<div>
<h1>Hello!</h1>
<CsvGenerator fileName="my-name" items={data}>
Download!
</CsvGenerator>
</div>
);
};
export default MyComponent;
import React from 'react';
import CsvGenerator from '@exlabs/react-csv-generator';
const MyComponent = () => {
return (
<div>
<h1>Hello!</h1>
<CsvGenerator
fileName="my-name"
baseEndpoint="https://api.punkapi.com/v2/beers"
>
Download!
</CsvGenerator>
</div>
);
};
export default MyComponent;
import React from 'react';
import CsvGenerator from '@exlabs/react-csv-generator';
const MyComponent = () => {
return (
<div>
<h1>Hello!</h1>
<CsvGenerator
fileName="my-name"
baseEndpoint="https://api.punkapi.com/v2/beers"
endpointDetails={{ page: 3, per_page: 10 }}
>
Download!
</CsvGenerator>
</div>
);
};
export default MyComponent;
total_pages
the component will try to fetch data from all pages and then generate the CSV. An example of the returned object might look like this:{
items: [{...}],
total_pages: 3,
}
The component will fetch https://api...?page=1
then https://api...?page=2
and finally https://api...?page=3
. Only one CSV file will be generated with data from all pages. There is a big chance that your pagination endpoint works this way. Don't forget to pass objectNameInResponse
prop. In the above example, it will be items
.
import React from 'react';
import CsvGenerator from '@exlabs/react-csv-generator';
const MyComponent = () => {
return (
<div>
<h1>Hello!</h1>
<CsvGenerator
fileName="my-name"
baseEndpoint="https://api.punkapi.com/v2/beers"
endpointDetails={{ page: 3, per_page: 10 }}
labels={{ boil_volume: 'Boil Volume', mash_temp: 'Mash Temperature' }}
>
Download!
</CsvGenerator>
</div>
);
};
export default MyComponent;
Coming soon
For easier writing tests, we add data-cy="csv-generator-btn"
attribute to the component's button. For example, if you are using Cypress.io you can easily get this item by cy.get('[data-cy="csv-generator-btn"]')
Opening generated CSV file in the newest Excel may be tricky. React CSV Generator uses commas as a separator so Excel needs to know about it.
File
and Open
Delimited
option and click Next
comma
as a delimiter and click Next
Finish
and enjoy 🎉MIT
FAQs
The React CSV generator
The npm package @exlabs/react-csv-generator receives a total of 0 weekly downloads. As such, @exlabs/react-csv-generator popularity was classified as not popular.
We found that @exlabs/react-csv-generator 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.