Class: JsxRosetta::IR::ReactHookCall
- Inherits:
-
Data
- Object
- Data
- JsxRosetta::IR::ReactHookCall
- 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
-
#hook ⇒ Object
readonly
Returns the value of attribute hook.
-
#library ⇒ Object
readonly
Returns the value of attribute library.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Attribute Details
#hook ⇒ Object (readonly)
Returns the value of attribute hook
252 253 254 |
# File 'lib/jsx_rosetta/ir/types.rb', line 252 def hook @hook end |
#library ⇒ Object (readonly)
Returns the value of attribute library
252 253 254 |
# File 'lib/jsx_rosetta/ir/types.rb', line 252 def library @library end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation
252 253 254 |
# File 'lib/jsx_rosetta/ir/types.rb', line 252 def operation @operation end |
#source ⇒ Object (readonly)
Returns the value of attribute source
252 253 254 |
# File 'lib/jsx_rosetta/ir/types.rb', line 252 def source @source end |