data.js — react Source File
Architecture documentation for data.js, a javascript file in the react codebase. 1 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR e04b3a10_94f9_7dd8_b7e7_ffd3a8a043f6["data.js"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] e04b3a10_94f9_7dd8_b7e7_ffd3a8a043f6 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 0107ee96_891d_0242_d19d_5ee01a72a676["render.js"] 0107ee96_891d_0242_d19d_5ee01a72a676 --> e04b3a10_94f9_7dd8_b7e7_ffd3a8a043f6 8a0252e2_1a4a_cc76_d526_583d20625d0c["Comments.js"] 8a0252e2_1a4a_cc76_d526_583d20625d0c --> e04b3a10_94f9_7dd8_b7e7_ffd3a8a043f6 style e04b3a10_94f9_7dd8_b7e7_ffd3a8a043f6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import {createContext, useContext} from 'react';
// Note: this file does not demonstrate a real data fetching strategy.
// We only use this to simulate data fetching happening on the server
// while the cache is populated on the client. In a real app, you would
// instead use a data fetching library or Server Components for this.
const DataContext = createContext(null);
export function DataProvider({children, data}) {
return <DataContext.Provider value={data}>{children}</DataContext.Provider>;
}
// In a real implementation the data would be streamed with the HTML.
// We haven't integrated this part yet, so we'll just use fake data.
const fakeData = [
"Wait, it doesn't wait for React to load?",
'How does this even work?',
'I like marshmallows',
];
export function useData() {
const ctx = useContext(DataContext);
if (ctx !== null) {
// This context is only provided on the server.
// It is here to simulate a suspending data fetch.
ctx.read();
}
return fakeData;
}
Domain
Subdomains
Functions
Dependencies
- react
Source
Frequently Asked Questions
What does data.js do?
data.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 data.js?
data.js defines 2 function(s): DataProvider, useData.
What does data.js depend on?
data.js imports 1 module(s): react.
What files import data.js?
data.js is imported by 2 file(s): Comments.js, render.js.
Where is data.js in the architecture?
data.js is located at fixtures/ssr2/src/data.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/ssr2/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free