App.js — react Source File
Architecture documentation for App.js, a javascript file in the react codebase. 5 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR d17ad6e6_5117_524c_98d3_e7c0244faa6b["App.js"] 5c033b86_56f7_5f1d_a1e8_ad727f4aca7d["Chrome.js"] d17ad6e6_5117_524c_98d3_e7c0244faa6b --> 5c033b86_56f7_5f1d_a1e8_ad727f4aca7d 8ec0492c_94fb_698e_bb73_4377ede788b3["Chrome"] d17ad6e6_5117_524c_98d3_e7c0244faa6b --> 8ec0492c_94fb_698e_bb73_4377ede788b3 ef975ced_d6a7_b295_dbfc_38e701d92f78["Page.js"] d17ad6e6_5117_524c_98d3_e7c0244faa6b --> ef975ced_d6a7_b295_dbfc_38e701d92f78 68b973bf_9634_6694_b5b6_773e48d34fe6["Page"] d17ad6e6_5117_524c_98d3_e7c0244faa6b --> 68b973bf_9634_6694_b5b6_773e48d34fe6 ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] d17ad6e6_5117_524c_98d3_e7c0244faa6b --> ac587885_e294_a1e9_b13f_5e7b920fdb42 2d6263d7_eed7_782a_80f5_608e8f93d047["render.js"] 2d6263d7_eed7_782a_80f5_608e8f93d047 --> d17ad6e6_5117_524c_98d3_e7c0244faa6b 780b47a9_ff3c_df25_09fc_3242a1e1eed4["index.js"] 780b47a9_ff3c_df25_09fc_3242a1e1eed4 --> d17ad6e6_5117_524c_98d3_e7c0244faa6b style d17ad6e6_5117_524c_98d3_e7c0244faa6b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import React, {
startTransition,
useLayoutEffect,
useEffect,
useState,
addTransitionType,
} from 'react';
import Chrome from './Chrome.js';
import Page from './Page.js';
const enableNavigationAPI = typeof navigation === 'object';
export default function App({assets, initialURL}) {
const [routerState, setRouterState] = useState({
pendingNav: () => {},
url: initialURL,
});
function navigate(url) {
if (enableNavigationAPI) {
window.navigation.navigate(url);
} else {
startTransition(() => {
setRouterState({
url,
pendingNav() {
window.history.pushState({}, '', url);
},
});
});
}
}
useEffect(() => {
if (enableNavigationAPI) {
window.navigation.addEventListener('navigate', event => {
if (!event.canIntercept) {
return;
}
const navigationType = event.navigationType;
const previousIndex = window.navigation.currentEntry.index;
const newURL = new URL(event.destination.url);
event.intercept({
handler() {
let promise;
startTransition(() => {
addTransitionType('navigation-' + navigationType);
if (navigationType === 'traverse') {
// For traverse types it's useful to distinguish going back or forward.
const nextIndex = event.destination.index;
if (nextIndex > previousIndex) {
addTransitionType('navigation-forward');
} else if (nextIndex < previousIndex) {
addTransitionType('navigation-back');
}
}
promise = new Promise(resolve => {
setRouterState({
url: newURL.pathname + newURL.search,
pendingNav: resolve,
});
});
});
return promise;
},
commit: 'after-transition', // plz ship this, browsers
});
});
} else {
window.addEventListener('popstate', () => {
// This should not animate because restoration has to be synchronous.
// Even though it's a transition.
startTransition(() => {
setRouterState({
url: document.location.pathname + document.location.search,
pendingNav() {
// Noop. URL has already updated.
},
});
});
});
}
}, []);
const pendingNav = routerState.pendingNav;
useLayoutEffect(() => {
pendingNav();
}, [pendingNav]);
return (
<Chrome title="Hello World" assets={assets}>
<Page url={routerState.url} navigate={navigate} />
</Chrome>
);
}
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does App.js do?
App.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in App.js?
App.js defines 1 function(s): App.
What does App.js depend on?
App.js imports 5 module(s): Chrome, Chrome.js, Page, Page.js, react.
What files import App.js?
App.js is imported by 2 file(s): index.js, render.js.
Where is App.js in the architecture?
App.js is located at fixtures/view-transition/src/components/App.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/view-transition/src/components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free