
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
angular-react-demo
Advanced tools
Access your Angular application from within React.
npm install angular-react react prop-types react-dom
A typical React component receiving props
import 'ngReact'
import angular from 'angular'
import {registerReactComponent} from 'react-angular'
const app = angular.module('your-project.react', ['react'])
function ExampleReactComponent (props) {
return (
<div>
The value is: {props.value}
</div>
)
}
registerReactComponent(app, 'exampleReactComponent', ExampleReactComponent)
<example-react-component value="'Hello World'"></example-react-component>
import 'ngReact'
import angular from 'angular'
import {
registerReactComponent,
reactify
} from 'react-angular'
const app = angular.module('your-project.react', ['react'])
app.component('exampleAngularComponent', {template: 'Angular inside React'})
const ExampleAngularComponent = reactify('exampleAngularComponent')
function ExampleReactComponent () {
return (
<div>
React rending Angular
<ExampleAngularComponent />
</div>
)
}
registerReactComponent(app, 'exampleReactNestingAngular', ExampleReactComponent)
<example-react-nesting-angular>
A React component that depends on Angular services.
Assume a Counter
service exists and the React component requires it
import {
registerReactComponent,
compose,
$inject,
$resolve
} from 'react-angular';
const app = angular.module('your-project.react', ['react'])
// Define the component dependencies (resolves, services, etc)
const connect = compose(
// Inject angular services,
$inject('Counter'),
// Define data resolvers
$resolve({
// Resolve the current count and observe changes.
count: $resolve.watch(['Counter', Counter => Counter.getCount()]),
// Resolve the count upon component mount without watching changes
originalCount: ['Counter', Counter => Counter.getCount()]
})
)
// Your React component
function ReactConter ({Counter, count, originalCount}) {
return (
<div>
<p>Count direction from CounterService: {Counter.getCount()}</p>
<p>Count from resolve: {count}</p>
<p>Original count (without watchers) from resolve: {originalCount}</p>
<button onClick={() => Counter.increment()}>+</button>
<button onClick={() => Counter.decrement()}>-</button>
</div>
)
}
// Register the component to be available in Angular
registerReactComponent(app, 'reactCounter', connect(ReactCounter))
<react-counter></react-counter>
FAQs
Access your Angular application from within React.
The npm package angular-react-demo receives a total of 2 weekly downloads. As such, angular-react-demo popularity was classified as not popular.
We found that angular-react-demo 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.