" /> " /> "/>

How to reference an input fields value in Riot.js?

521 Views Asked by At
<hello-world>
  <form action="">
    <input type="text" ref="inputValue" placeholder="type a name" />
    <input type="submit" onclick="{trigger_printName}" />
  </form>

  <script>

    this.trigger_printName = e => {
      e.preventDefault();
      console.log(e.target.value);
      console.log(this.refs.inputValue.value)
    };
  </script>
</hello-world>

I am trying to access the value of the users input in the input field. Console logging e.target.value returns an empty string and console logging this.refs.inputValue.value says "Cannot read property 'inputValue' of undefined"

1

There are 1 best solutions below

0
Justin Oswald On BEST ANSWER

Turns out I had some how installed a very old version of riot+compiler.min.js. after updating the file to the current v3.13.2 it works just fine.