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.
react2angular
Advanced tools
The easiest way to embed React components in Angular 1 apps! (opposite of angular2react)
# Using Yarn:
yarn add react2angular react react-dom prop-types
# Or, using NPM:
npm install react2angular react react-dom prop-types --save
import { Component } from 'react'
class MyComponent extends Component {
render() {
return <div>
<p>FooBar: {this.props.fooBar}</p>
<p>Baz: {this.props.baz}</p>
</div>
}
}
import { react2angular } from 'react2angular'
angular
.module('myModule', [])
.component('myComponent', react2angular(MyComponent, ['fooBar', 'baz']))
Note: If you defined propTypes
on your component, they will be used to compute component's bindings, and you can omit the 2nd argument:
...
.component('myComponent', react2angular(MyComponent))
If propTypes
are defined and you passed in a 2nd argument, the argument will override propTypes
.
<my-component
foo-bar="3"
baz="'baz'"
></my-component>
It's easy to pass services/constants/etc. to your React component: just pass them in as the 3rd argument, and they will be available in your component's Props. For example:
import { Component } from 'react'
import { react2angular } from 'react2angular'
class MyComponent extends Component {
state = {
data: ''
}
componentDidMount() {
this.props.$http.get('/path').then(res =>
this.setState({ data: res.data })
)
}
render() {
return <div>
{ this.props.FOO }
{ this.state.data }
</div>
}
}
angular
.module('myModule', [])
.constant('FOO', 'FOO!')
.component('myComponent', react2angular(MyComponent, [], ['$http', 'FOO']))
Note: If you have an injection that matches the name of a prop, then the value will be resolved with the injection, not the prop.
npm test
Apache2
FAQs
The easiest way to embed React components in Angular 1 apps!
We found that react2angular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
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.