Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-lazily
Advanced tools
React.lazy wrapper that works with allows you to destruct imported module, so it will work with non default exports
react-lazily
is a simple wrapper around React.lazy
(or loadable
from @loadable/component
) that supports named imports.
Consider a component MyComponent
that is exported with a default export:
export default MyComponent;
Per React docs, you could use React.lazy
as follows:
const MyComponent = React.lazy(() => import('./MyComponent'));
However, if the component is exported with a named export:
export const MyComponent = ...
You would have to use React.lazy
like this:
But if the component is exported with named export export const MyComponent = ...
then you have to do:
const MyComponent = React.lazy(() =>
import('./MyComponent').then((module) => ({ default: module.MyComponent }))
);
With react-lazily
it becomes:
const { MyComponent } = lazily(() => import('./MyComponent'));
See the live example: https://codesandbox.io/s/react-lazily-example-p7hyj
import React, { Suspense } from 'react';
import { lazily } from 'react-lazily';
const { MyComponent } = lazily(() => import('./MyComponent'));
const App = () => {
const [open, setOpen] = React.useReducer(() => true, false);
return (
<>
{open ? (
<Suspense fallback={<div>Loading...</div>}>
<MyComponent />
</Suspense>
) : (
<button onClick={setOpen}>Load</button>
)}
</>
);
};
Don't forget to install @loadable/component
first.
import React from 'react';
import { loadable } from 'react-lazily/loadable';
const { MyComponent } = loadable(() => import('./MyComponent'), {
fallback: <div>Loading...</div>,
});
const App = () => {
const [open, setOpen] = React.useReducer(() => true, false);
return (
<>
{open ? <MyComponent /> : <button onClick={setOpen}>Load</button>}
</>
);
};
FAQs
React.lazy wrapper that works with allows you to destruct imported module, so it will work with non default exports
The npm package react-lazily receives a total of 22,821 weekly downloads. As such, react-lazily popularity was classified as popular.
We found that react-lazily 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.