Class: JsxRosetta::IR::ReactHookCall

Inherits:
Data
  • Object
show all
Includes:
Node
Defined in:
lib/jsx_rosetta/ir/types.rb

Overview

A hook invocation detected in the component body. Covers React’s built-in hooks plus framework hooks we recognize (Apollo’s ‘useQuery`/ `useMutation`/etc., Next.js’s ‘useRouter`/`usePathname`/etc.). Surfaced separately from local_bindings so backends can emit a more specific TODO pointing at the Rails equivalent for each library, instead of a generic “translate this JS”.

hook : String — hook function name (‘“useState”`, `“useQuery”`, …) source : String — verbatim JS of the entire statement. library : Symbol — `:react`, `:apollo`, or `:next_js`. Backends

group hooks by library and emit one TODO block per group,
since each library maps to a different Rails analog.

operation : String | nil — for Apollo hooks called with a bare-Identifier

first argument (`useQuery(GET_USERS_QUERY, …)`), the
captured operation name. nil when the first argument is
not a simple Identifier, or when the hook isn't Apollo.
Backends echo it in the TODO so the reviewer can match
the operation back to its GraphQL document and to the
Rails controller / model fetch it should become.

Instance Attribute Summary collapse

Instance Attribute Details

#hookObject (readonly)

Returns the value of attribute hook

Returns:

  • (Object)

    the current value of hook



107
108
109
# File 'lib/jsx_rosetta/ir/types.rb', line 107

def hook
  @hook
end

#libraryObject (readonly)

Returns the value of attribute library

Returns:

  • (Object)

    the current value of library



107
108
109
# File 'lib/jsx_rosetta/ir/types.rb', line 107

def library
  @library
end

#operationObject (readonly)

Returns the value of attribute operation

Returns:

  • (Object)

    the current value of operation



107
108
109
# File 'lib/jsx_rosetta/ir/types.rb', line 107

def operation
  @operation
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



107
108
109
# File 'lib/jsx_rosetta/ir/types.rb', line 107

def source
  @source
end