Comparing version 0.0.28 to 0.0.29
{ | ||
"name": "forgo", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"main": "./dist", | ||
@@ -5,0 +5,0 @@ "author": "Jeswin Kumar<jeswinpk@agilehead.com>", |
@@ -100,5 +100,5 @@ # forgo | ||
You can access and read form input elements using regular DOM APIs. | ||
To access the actual DOM elements corresponding to your markup (and the values contained within them), you need to use the ref attribute in the markup. An object referenced by the ref attribute in an element's markup will have its 'value' property set to the actual DOM element when it gets created. | ||
Like this: | ||
Here's an example: | ||
@@ -112,3 +112,3 @@ ```jsx | ||
function onClick() { | ||
const inputElement = document.getElementById("myinput"); | ||
const inputElement = myInputRef.value; | ||
alert(inputElement.value); // Read the text input! | ||
@@ -119,3 +119,3 @@ } | ||
<div> | ||
<input type="text" id="myinput" /> | ||
<input type="text" ref={myInputRef} /> | ||
<button onclick={onClick}>Click me!</button> | ||
@@ -129,25 +129,8 @@ </div> | ||
But there's also another way to do this, without requiring you to assign an id. An object referenced by the ref attribute in an element's markup will have its value property set to the actual DOM element. | ||
You can access and read form input elements using regular DOM APIs as well. For example, the following code will work just fine if you assign an id to the input element. | ||
So you could do this as well: | ||
```jsx | ||
function Component(props) { | ||
const myInputRef = {}; | ||
return { | ||
render(props, args) { | ||
function onClick() { | ||
const inputElement = myInputRef.value; | ||
alert(inputElement.value); // Read the text input! | ||
} | ||
return ( | ||
<div> | ||
<input type="text" ref={myInputRef} /> | ||
<button onclick={onClick}>Click me!</button> | ||
</div> | ||
); | ||
}, | ||
}; | ||
function onClick() { | ||
const inputElement = document.getElementById("myinput"); | ||
alert(inputElement.value); | ||
} | ||
@@ -154,0 +137,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87167
317