orange4 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +35 -2
  2. package/package.json +7 -4
package/README.md CHANGED
@@ -1,3 +1,36 @@
1
- # Temporary Holding Version
1
+ # useRef Example in React
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `useRef` holds a mutable value that persists across renders, and is commonly used to access a DOM element directly.
4
+
5
+ ```jsx
6
+ import { useRef } from "react";
7
+
8
+ export default function App() {
9
+ const inputRef = useRef(null);
10
+
11
+ function clearAndFocus() {
12
+ inputRef.current.value = "";
13
+ inputRef.current.focus();
14
+ }
15
+
16
+ function showText() {
17
+ alert(inputRef.current.value);
18
+ }
19
+
20
+ return (
21
+ <>
22
+ <input ref={inputRef} placeholder="Type something" />
23
+ <button onClick={clearAndFocus}>Clear and Focus</button>
24
+ <button onClick={showText}>Show Text</button>
25
+ </>
26
+ );
27
+ }
28
+ ```
29
+
30
+ ## Output
31
+
32
+ ```
33
+ [ Type something ] [ Clear and Focus ] [ Show Text ]
34
+ Show Text: an alert shows whatever is typed in the box.
35
+ Clear and Focus: the box is emptied and the cursor blinks inside it.
36
+ ```
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "orange4",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "React useRef example",
5
+ "license": "MIT",
6
+ "files": [
7
+ "README.md"
8
+ ]
9
+ }