Class: JsxRosetta::IR::Component

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

Overview

A translated component definition. The root of a lowered IR tree.

name : String — component name as it appears in JSX (e.g. “Button”). props : [Prop] body : Node — usually an Element or Fragment. rest_prop_name : String | nil — name of a rest-destructured prop

(`function X({ a, ...rest })`). When non-nil, the
backend should generate a `**rest` initializer kwarg
and make it available via `@rest_prop_name`.

local_bindings : [LocalBinding] — non-JSX local ‘const` bindings inside

the component body. Backends typically render these as
a TODO comment block since arbitrary JS-to-Ruby
translation isn't attempted.

stimulus_methods : [StimulusMethod] — event handlers extracted from

inline arrows / const-bound arrows used in onX={...}.
When non-empty, backends should emit a sibling
Stimulus controller file alongside the .rb/.erb pair.

react_hooks : [ReactHookCall] — calls to React hooks (useState,

useEffect, useRef, useContext, useMemo, useCallback,
useReducer, useImperativeHandle, useLayoutEffect).
Surfaced as a distinct TODO block so the human
reviewer knows to translate behavior to Stimulus
and state to server-side rendering.

Instance Attribute Summary collapse

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def body
  @body
end

#local_bindingsObject (readonly)

Returns the value of attribute local_bindings

Returns:

  • (Object)

    the current value of local_bindings



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def local_bindings
  @local_bindings
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def name
  @name
end

#propsObject (readonly)

Returns the value of attribute props

Returns:

  • (Object)

    the current value of props



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def props
  @props
end

#react_hooksObject (readonly)

Returns the value of attribute react_hooks

Returns:

  • (Object)

    the current value of react_hooks



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def react_hooks
  @react_hooks
end

#rest_prop_nameObject (readonly)

Returns the value of attribute rest_prop_name

Returns:

  • (Object)

    the current value of rest_prop_name



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def rest_prop_name
  @rest_prop_name
end

#stimulus_methodsObject (readonly)

Returns the value of attribute stimulus_methods

Returns:

  • (Object)

    the current value of stimulus_methods



33
34
35
# File 'lib/jsx_rosetta/ir/types.rb', line 33

def stimulus_methods
  @stimulus_methods
end