text: Title: gradio.State is always null in JavaScript callbacks
  Body: ### Describe the bug
  
  I'm trying to extend `gr.Gallery` component with custom logic. The idea is to scroll it to the position selected by the user.
  I wrote a custom JS handler which does the job and it works if I provide `gr.Number` component as input. However, I can not
  do the same with `gr.State`. The debugger shows that the passed value is always `null`.
  
  **Expected behavior**: should be able to pass either gr.Number or gr.State as inputs to JS handlers
  
  ### Have you searched existing issues?  🔎
  
  - [x] I have searched and found no existing issues
  
  ### Reproduction
  
  ```python
  import gradio as gr
  
  extra_js_scripts = (
      r"""
      <script>
      const scrollToIndex = (index) => {
          const thumbnails = document.querySelectorAll('.thumbnail-item');
          if (index !== null && index >= 0 && index < thumbnails.length) {
              thumbnails[index].scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
          } else {
              console.error('Index out of bounds');
          }
      };
      </script>
      """
  )
  
  with gr.Blocks(head=extra_js_scripts) as demo:
      current_index = gr.State(0)
      gallery = gr.Gallery(columns=1,
                      object_fit='contain',
                      allow_preview=False,
                      show_download_button=False,
                      show_fullscreen_button=False)
  
      index_input = gr.Number(label="Image Index", value=0)
      scroll_button = gr.Button("Scroll to Image")
  
      index_input.change(fn=lambda x: x, inputs=index_input, outputs=current_index)
  
      # This does not work
      scroll_button.click(fn=None, js="(index) => scrollToIndex(index)", inputs=current_index)
  
      # This works
      # scroll_button.click(fn=None, js="(index) => scrollToIndex(index)", inputs=index_input)
  
      demo.load(lambda: ["https://placebear.com/200/200" for _ in range(6)], outputs=gallery)
  
  demo.launch()
  
  ```
  
  
  ### Screenshot
  
  <img width="1673" alt="Image" src="https://github.com/user-attachments/assets/f1c212c1-2b81-4de6-b2a3-6e8d02173d5a" />
  
  ### Logs
  
  ```shell
  
  ```
  
  ### System Info
  
  ```shell
  Gradio Environment Information:
  ------------------------------
  Operating System: Linux
  gradio version: 5.12.0
  gradio_client version: 1.5.4
  
  ------------------------------------------------
  gradio dependencies in your environment:
  
  aiofiles: 23.2.1
  anyio: 4.8.0
  audioop-lts is not installed.
  fastapi: 0.115.6
  ffmpy: 0.5.0
  gradio-client==1.5.4 is not installed.
  httpx: 0.28.1
  huggingface-hub: 0.27.1
  jinja2: 3.1.5
  markupsafe: 2.1.5
  numpy: 1.26.4
  orjson: 3.10.15
  packaging: 24.2
  pandas: 2.2.3
  pillow: 11.1.0
  pydantic: 2.10.5
  pydub: 0.25.1
  python-multipart: 0.0.20
  pyyaml: 6.0.2
  ruff: 0.2.2
  safehttpx: 0.1.6
  semantic-version: 2.10.0
  starlette: 0.41.3
  tomlkit: 0.13.2
  typer: 0.15.1
  typing-extensions: 4.12.2
  urllib3: 2.3.0
  uvicorn: 0.34.0
  authlib; extra == 'oauth' is not installed.
  itsdangerous; extra == 'oauth' is not installed.
  
  
  gradio_client dependencies in your environment:
  
  fsspec: 2024.12.0
  httpx: 0.28.1
  huggingface-hub: 0.27.1
  packaging: 24.2
  typing-extensions: 4.12.2
  websockets: 14.2
  ```
  
  ### Severity
  
  I can work around it