@hitesh0009/react-native-basic-form 1.3.1 → 1.3.2

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.
package/README.md CHANGED
@@ -350,5 +350,3 @@ Please keep PRs:
350
350
 
351
351
  MIT
352
352
 
353
- ```
354
-
@@ -3,27 +3,58 @@ import { View } from "react-native";
3
3
  import { Form } from "react-native-basic-form";
4
4
 
5
5
  export default function App() {
6
+ // 👉 Form state is owned by YOU, not by the Form component
7
+ // The library is stateless by design
6
8
  const [name, setName] = useState("");
7
9
 
8
- return (
9
- <View style={{ padding: 16 }}>
10
- <Form
11
- data={[
12
- {
13
- id: "name",
14
- label: "Name",
15
- input: {
16
- placeholder: "Enter your name",
17
- value: name,
18
- onChangeText: ()=>{},
19
- },
20
- button: {
21
- lable: "name",
22
- onPress: () => {},
10
+ // 👉 Schema controls the entire form UI
11
+ // Changing this JSON changes the form
12
+ const formSchema = [
13
+ {
14
+ // Layout block: controls how children are arranged
15
+ layout: "column",
16
+ spacing: 16, // space between fields
17
+
18
+ // Children = actual form fields
19
+ children: [
20
+ {
21
+ // Input field
22
+ type: "input",
23
+ label: "Name",
24
+
25
+ // All TextInput behavior goes inside inputProps
26
+ inputProps: {
27
+ placeholder: "Enter your name",
28
+ value: name, // controlled value
29
+ onChangeText: setName // update state
30
+ },
31
+ },
32
+
33
+ {
34
+ // Button field
35
+ type: "button",
36
+ label: "Submit",
37
+
38
+ // Button behavior goes inside buttonProps
39
+ buttonProps: {
40
+ buttonText: "Submit",
41
+ onPress: () => {
42
+ // Access state directly
43
+ console.log("Name:", name);
23
44
  },
24
45
  },
25
- ]}
26
- />
46
+ },
47
+ ],
48
+ },
49
+ ];
50
+
51
+ return (
52
+ <View style={{ padding: 16 }}>
53
+ {/*
54
+ 👉 Form only renders what the schema describes
55
+ 👉 No internal state, no validation, no logic
56
+ */}
57
+ <Form schema={formSchema} />
27
58
  </View>
28
59
  );
29
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitesh0009/react-native-basic-form",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "A lightweight, data-driven form renderer for React Native with fully controlled inputs and flexible styling.",
5
5
  "keywords": [
6
6
  "react-native",