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.
@backium/use-instance
Advanced tools
Library to get Object Instances via context. It can be useful when you want to access your object instances from other React components.
Library to get Object Instances via context. It can be useful when you want to access your object instances from other React components.
In order to install the package. use the following command:
yarn add @backium/use-instance
First, you should add InstanceProvider
.
import { InstanceProvider } from '@backium/use-instance';
import App from './App';
export default () => {
return (
<InstanceProvider>
<App />
</InstanceProvider>
);
};
Add object instance to the store
import { InstanceProvider, useInstance } from '@backium/use-instance';
import SomeComponent from './SomeComponent';
class SecretManager {
get() {
return 'supersecret';
}
}
const App = () => {
const { setInstance } = useInstance();
const secretManager = new SecretManager();
React.useEffect(() => {
setInstance('secretManager', secretManager);
}, []);
return <SomeComponent />;
};
Use object instance from another component
import { useInstance } from '@backium/use-instance';
const SomeComponent = () => {
const [secret, setSecret] = React.useState('');
const { instances, getInstance } = useInstance();
React.useEffect(() => {
const instance = getInstance<SecretManager>('secretManager');
const secretText = instance?.get();
if (secretText) {
setSecret(secretText);
}
}, [instances]);
return <div>{secret}</div>;
};
export default SomeComponent;
FAQs
Library to get Object Instances via context. It can be useful when you want to access your object instances from other React components.
We found that @backium/use-instance 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’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.