Gathering detailed insights and metrics for @uirouter/react-hybrid
Gathering detailed insights and metrics for @uirouter/react-hybrid
Gathering detailed insights and metrics for @uirouter/react-hybrid
Gathering detailed insights and metrics for @uirouter/react-hybrid
npm install @uirouter/react-hybrid
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
88 Stars
707 Commits
37 Forks
6 Watching
17 Branches
15 Contributors
Updated on 03 Apr 2024
TypeScript (58.45%)
JavaScript (26.59%)
HTML (11.21%)
Shell (2.19%)
CSS (1.56%)
Cumulative downloads
Total Downloads
Last day
-35.2%
748
Compared to previous day
Last week
-15%
5,541
Compared to previous week
Last month
1.5%
26,145
Compared to previous month
Last year
0.5%
310,319
Compared to previous year
3
This package enables UI-Router to route to both AngularJS components (and/or templates) and React components. Your app will be hosted by AngularJS while you incrementally migrate to React.
1import { ReactAboutComponent } from "./about.component"; 2 3/// ... 4 5$stateProvider.state({ 6 name: 'home', 7 url: '/home', 8 component: 'ng1HomeComponent' // AngularJS component or directive name 9}) 10 11.state({ 12 name: 'about', 13 url: '/about', 14 component: ReactAboutComponent // React component class reference 15}); 16 17.state({ 18 name: 'other', 19 url: '/other', 20 template: '<h1>Other</h1>', // AngularJS template/controller 21 controller: function($scope) { /* do stuff */ } 22}) 23
When routing to a React component, that component can use the standard
React directives (UIView, UISref, UISrefActive) from @uirouter/react
.
When routing to an AngularJS component or template, that component uses the standard
AngularJS directives (ui-view, ui-sref, ui-sref-active) from @uirouter/angularjs
.
Remove angular-ui-router
(or @uirouter/angularjs
) from your package.json and replace it with @uirouter/react-hybrid
.
Add the react
and react-dom
dependencies.
dependencies: {
...
"angular": "^1.6.0",
"react": "^15.4.0",
"react-dom": "^15.4.0",
...
"@uirouter/react-hybrid": "^0.0.8",
...
}
1import { UI_ROUTER_REACT_HYBRID } from '@uirouter/react-hybrid'; 2let ng1module = angular.module("myApp", ['ui.router', UI_ROUTER_REACT_HYBRID]);
Your existing AngularJS routes work the same as before.
var foo = {
name: 'foo',
url: '/foo',
component: 'fooComponent'
};
$stateProvider.state(foo);
var bar = {
name: 'foo.bar',
url: '/bar',
templateUrl: '/bar.html',
controller: 'BarController'
};
$stateProvider.state(bar);
Use component:
in your state declaration.
var leaf = {
name: 'foo.bar.leaf',
url: '/leaf',
component: MyReactComponentClass
};
$stateProvider.state(leaf);
An AngularJS <ui-view>
can have default content.
This default content is rendered when no state is filling the ui-view
with a component.
For example, a parent state may render a ui-view
portal, but want Default Content
to display
when no child state is active: <ui-view>Default Content</ui-view>
.
The @uirouter/react-hybrid
project sets the default content to an adapter component, <react-ui-view-adapter>
.
The react-ui-view-adapter
then renders a React <UIView/>
.
When a state loads an AngularJS view into the AngularJS <ui-view>
, it replaces the react-ui-view-adapter
default content.
When a state loads a React Component into the React <UIView/>
component, it is nested inside the AngularJS components like so:
1<ui-view> // angularjs 2 <react-ui-view-adapter> // angularjs 3 <UIView> // react 4 <RoutedReactComponent/> //react 5 </UIView> 6 </react-ui-view-adapter> 7</ui-view>
In AngularJS, each <ui-view>
provides the state context to its children elements, such as ui-sref
or ui-view
.
The state context allows a ui-sref
to use relative links, for example.
AngularJS provides this context by setting hidden data on its DOM element, using angular.element(el).data('$uiView')
.
Any nested ui-view
or ui-sref
fetches the context by asking for angular.element(childel).inheritedData('$uiView')
.
In React, each UIView
provides the state context to its children elements using React context.
The nested UIView
or UISref
fetches the state context using the React context API.
There is some glue provided by @uirouter/react-hybrid
which bridges these two context mechanisms.
When a React UIView
component is rendered, it is wrapped in a UIRouterReactContext
component.
The component finds the state context by looking first via React props, and second via AngularJS DOM data.
It then provides the state context to its children using React props.
The <react-ui-view-adapter>
wraps a React UIView
component.
When the react UIView
is filled by a state's react component, the react-ui-view-adapter
gets the state context for the newly filled UIView
.
It then provides that context to AngularJS components using AngularJS DOM data.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/17 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More