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.
@ngeenx/ngx-react
Advanced tools
This simple Angular library integrates React components into Angular applications with ease. It is based on React createElement function and Angular directives (as standalone components). See source code here.
[!WARNING] This package is experimental. There may be possible performance problems, memory leaks and similar problems. It is your responsibility to use it.
Please install with peer dependencies react
and react-dom
using your favorite package manager.
Package Version | Angular Version |
---|---|
1.x.x | 17.x.x |
2.x.x | 18.x.x |
PNPM
pnpm i react react-dom @ngeenx/ngx-react
NPM
npm i react react-dom @ngeenx/ngx-react
[!NOTE] Addionaly, you can install
@types/react
and@types/react-dom
for TypeScript support.
Import ReactComponentDirective
in your standalone component or module.
import { ReactComponentDirective } from '@ngeenx/ngx-react';
@NgModule({
imports: [
...
ReactComponentDirective
]
})
tsconfig.json
Add the following to your tsconfig.json
file to allow importing .tsx
files in Angular Project.
{
"compilerOptions": {
"jsx": "react",
...
}
}
Create a wrapper component for your React component. We will use this component to pass props to the React component.
// ReactApp.tsx
import React, { FC, useState } from 'react';
const ReactApp: FC<any> = ({ initialInputValue }: any) => {
const [inputValue, setInputValue] = useState(initialInputValue);
const handleChange = (event: any) => {
setInputValue(event.target.value);
};
return (
<div>
<label htmlFor="myInput">Label:</label>
<input
type="text"
id="myInput"
value={inputValue}
onChange={handleChange}
/>
<p>Input Value: {inputValue}</p>
</div>
);
};
export default ReactApp;
// app.component.ts
import { Component, NgModule } from '@angular/core';
import ReactApp from './ReactApp';
@Component({
selector: "app-component",
template: `<div
[reactComponent]="ReactApp"
[props]="props"
></div>`,
standalone: true,
imports: [ReactComponentDirective],
})
export class StandaloneComponent {
public ReactApp: typeof ReactApp = ReactApp;
public props = {
initialInputValue: "Some Value"
}
}
FAQs
Embed React components in Angular projects
The npm package @ngeenx/ngx-react receives a total of 0 weekly downloads. As such, @ngeenx/ngx-react popularity was classified as not popular.
We found that @ngeenx/ngx-react demonstrated a healthy version release cadence and project activity because the last version was released less than 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.