Home / Function/ getReanimatedModuleType() — react Function Reference

getReanimatedModuleType() — react Function Reference

Architecture documentation for the getReanimatedModuleType() function in Globals.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25["getReanimatedModuleType()"]
  38c44267_cdd2_9815_ebad_fa6761ba5934["Globals.ts"]
  4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25 -->|defined in| 38c44267_cdd2_9815_ebad_fa6761ba5934
  bec8431d_08f7_cef1_8a71_8be17fc7a31a["constructor()"]
  bec8431d_08f7_cef1_8a71_8be17fc7a31a -->|calls| 4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25
  d0882928_65af_dce8_5416_84ed7f492587["addHook()"]
  4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25 -->|calls| d0882928_65af_dce8_5416_84ed7f492587
  a77ff0f7_0c98_02df_9507_6da9eca5fbb5["addFunction()"]
  4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25 -->|calls| a77ff0f7_0c98_02df_9507_6da9eca5fbb5
  fdd1014d_2fa9_cdec_af9b_b2e2bada1088["addObject()"]
  4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25 -->|calls| fdd1014d_2fa9_cdec_af9b_b2e2bada1088
  style 4ba5c3ad_186f_8c38_7db0_a6d2e5ee2b25 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts lines 1079–1150

export function getReanimatedModuleType(registry: ShapeRegistry): ObjectType {
  // hooks that freeze args and return frozen value
  const frozenHooks = [
    'useFrameCallback',
    'useAnimatedStyle',
    'useAnimatedProps',
    'useAnimatedScrollHandler',
    'useAnimatedReaction',
    'useWorkletCallback',
  ];
  const reanimatedType: Array<[string, BuiltInType]> = [];
  for (const hook of frozenHooks) {
    reanimatedType.push([
      hook,
      addHook(registry, {
        positionalParams: [],
        restParam: Effect.Freeze,
        returnType: {kind: 'Poly'},
        returnValueKind: ValueKind.Frozen,
        noAlias: true,
        calleeEffect: Effect.Read,
        hookKind: 'Custom',
      }),
    ]);
  }

  /**
   * hooks that return a mutable value. ideally these should be modelled as a
   * ref, but this works for now.
   */
  const mutableHooks = ['useSharedValue', 'useDerivedValue'];
  for (const hook of mutableHooks) {
    reanimatedType.push([
      hook,
      addHook(registry, {
        positionalParams: [],
        restParam: Effect.Freeze,
        returnType: {kind: 'Object', shapeId: ReanimatedSharedValueId},
        returnValueKind: ValueKind.Mutable,
        noAlias: true,
        calleeEffect: Effect.Read,
        hookKind: 'Custom',
      }),
    ]);
  }

  // functions that return mutable value
  const funcs = [
    'withTiming',
    'withSpring',
    'createAnimatedPropAdapter',
    'withDecay',
    'withRepeat',
    'runOnUI',
    'executeOnUIRuntimeSync',
  ];
  for (const fn of funcs) {
    reanimatedType.push([
      fn,
      addFunction(registry, [], {
        positionalParams: [],
        restParam: Effect.Read,
        returnType: {kind: 'Poly'},
        calleeEffect: Effect.Read,
        returnValueKind: ValueKind.Mutable,
        noAlias: true,
      }),
    ]);
  }

  return addObject(registry, null, reanimatedType);
}

Subdomains

Called By

Frequently Asked Questions

What does getReanimatedModuleType() do?
getReanimatedModuleType() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts.
Where is getReanimatedModuleType() defined?
getReanimatedModuleType() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts at line 1079.
What does getReanimatedModuleType() call?
getReanimatedModuleType() calls 3 function(s): addFunction, addHook, addObject.
What calls getReanimatedModuleType()?
getReanimatedModuleType() is called by 1 function(s): constructor.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free