Skip to content

Commit 0949929

Browse files
committed
Move links from github -> /docs
1 parent 289ff28 commit 0949929

15 files changed

+139
-140
lines changed

articles/Array-fields.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Array fields
22

3-
To create dynamic array fields, you should use the [`ArrayForm`](https://github.com/CodeStix/typed-react-form/wiki/ArrayForm) component or [`useArrayForm`](https://github.com/CodeStix/typed-react-form/wiki/useArrayForm) hook. These are wrappers around [`useChildForm`](https://github.com/CodeStix/typed-react-form/wiki/useChildForm) which provide useful functions and optimizations for arrays.
3+
To create dynamic array fields, you should use the [`ArrayForm`](/docs/ArrayForm) component or [`useArrayForm`](/docs/useArrayForm) hook. These are wrappers around [`useChildForm`](/docs/useChildForm) which provide useful functions and optimizations for arrays.
44

5-
- [ArrayForm](https://github.com/CodeStix/typed-react-form/wiki/ArrayForm)
6-
- [useArrayForm](https://github.com/CodeStix/typed-react-form/wiki/useArrayForm)
5+
- [ArrayForm](/docs/ArrayForm)
6+
- [useArrayForm](/docs/useArrayForm)
77

8-
If you have an array field with a constant size, you should probably just use [`ChildForm`](https://github.com/CodeStix/typed-react-form/wiki/ChildForm). (See bottom for examples)
8+
If you have an array field with a constant size, you should probably just use [`ChildForm`](/docs/ChildForm). (See bottom for examples)
99

1010
**Note on keys**: you **should** use the index as key, this seems against nature at first, but remember that this library does not rerender each time something in the array changes. When 2 array items get swapped, it does not rerender either, only when the array size changes, it rerenders. For this reason, it is not a problem (and it's recommended) to use index as the key. (This can change in the future)
1111

@@ -177,7 +177,7 @@ function ShoppingListItemForm(props: { parent: FormState<ShoppingListItem[]>, in
177177

178178
## Fixed array example
179179

180-
A fixed array always has the same size, [`ChildForm`](https://github.com/CodeStix/typed-react-form/wiki/ChildForm) is used, and the index into the array is given using the name prop.
180+
A fixed array always has the same size, [`ChildForm`](/docs/ChildForm) is used, and the index into the array is given using the name prop.
181181

182182
✔️ **Fixed array field containing strings**
183183

articles/ArrayForm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ArrayForm
22

3-
A component that provides array manipulation functions and optimizations. This is a wrapper around [`useArrayForm`](https://github.com/CodeStix/typed-react-form/wiki/useArrayForm). The only difference is that this component does not render its content when the array is null/undefined ([is togglable](https://github.com/CodeStix/typed-react-form/wiki/Toggling-a-field)).
3+
A component that provides array manipulation functions and optimizations. This is a wrapper around [`useArrayForm`](/docs/useArrayForm). The only difference is that this component does not render its content when the array is null/undefined ([is togglable](/docs/Toggling-a-field)).
44

55
## Props
66

@@ -36,4 +36,4 @@ The render function provides an object parameter, containing the following field
3636

3737
## Usage
3838

39-
See [Array fields](https://github.com/CodeStix/typed-react-form/wiki/Array-fields).
39+
See [Array fields](/docs/Array-fields).

articles/ChildForm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ChildForm
22

3-
Use the `ChildForm` component if you want to make fields inside an object field available to inputs. This is a wrapper around [`useChildForm`](https://github.com/CodeStix/typed-react-form/wiki/useChildForm).
3+
Use the `ChildForm` component if you want to make fields inside an object field available to inputs. This is a wrapper around [`useChildForm`](/docs/useChildForm).
44

55
## Props
66

@@ -22,6 +22,6 @@ A function that renders, and creates inputs for the child form, which is passed
2222

2323
## Advanced
2424

25-
You can also use this component on array fields (index as name), but [`ArrayForm`](https://github.com/CodeStix/typed-react-form/wiki/ArrayForm) or [`useArrayForm`](https://github.com/CodeStix/typed-react-form/wiki/useArrayForm) is preferred when you want to create [dynamic array fields](https://github.com/CodeStix/typed-react-form/wiki/Array-fields). It provides useful array manipulation functions and optimizations.
25+
You can also use this component on array fields (index as name), but [`ArrayForm`](/docs/ArrayForm) or [`useArrayForm`](/docs/useArrayForm) is preferred when you want to create [dynamic array fields](/docs/Array-fields). It provides useful array manipulation functions and optimizations.
2626

2727
This component does not render its content when the form is empty (happens when its parent field has been assigned `null`, `undefined` or `{}`).

articles/FormError.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ function CustomFormError<T>(props: { form: FormState<T>; name: keyof T }) {
4242

4343
```
4444

45-
You can also create custom input components, look [here](https://github.com/CodeStix/typed-react-form/wiki/Custom-inputs).
45+
You can also create custom input components, look [here](/docs/Custom-inputs).

articles/FormInput.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ Make sure you pass along a `value` too, this is the value that will be set when
152152

153153
---
154154

155-
All of the input components are wrappers and abstractions around the [`useListener`](https://github.com/CodeStix/typed-react-form/wiki/useListener) hook. Using this hook, you can create your own [custom inputs](https://github.com/CodeStix/typed-react-form/wiki/Custom-inputs).
155+
All of the input components are wrappers and abstractions around the [`useListener`](/docs/useListener) hook. Using this hook, you can create your own [custom inputs](/docs/Custom-inputs).

articles/FormState.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Maps field names to errors. Can be set with `setErrors()`.
3838

3939
#### `state` **(readonly)**
4040

41-
Gets the current form state. Form state contains variables like `isSubmitting` etc. This state is synced with parent and child forms. Can be set with [`setState()`](https://github.com/CodeStix/typed-react-form/wiki/FormState#setstatenewstate).
41+
Gets the current form state. Form state contains variables like `isSubmitting` etc. This state is synced with parent and child forms. Can be set with [`setState()`](/docs/FormState#setstatenewstate).
4242

43-
See [`useForm`](https://github.com/CodeStix/typed-react-form/wiki/useForm) for a guide on how to create custom form state.
43+
See [`useForm`](/docs/useForm) for a guide on how to create custom form state.
4444

4545
---
4646

articles/Getting-started.md

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting started
22

3-
Welcome to the **typed-react-form** documentation!
3+
Welcome to the **typed-react-form** documentation!
44

55
## Step 1: Install
66

@@ -11,17 +11,18 @@ npm install --save typed-react-form
1111
yarn add typed-react-form
1212
```
1313

14-
This library works with both **Javascript** and **Typescript**. **Typescript** is certainly preferred because of the enforced type-checking!
14+
This library works with both **Javascript** and **Typescript**. **Typescript** is certainly preferred because of the enforced type-checking!
1515

1616
## Step 2: Creating a form
1717

1818
### Using the `useForm` hook
1919

20-
A form always starts with the `useForm` hook call, this function returns a form state manager ([FormState](https://github.com/CodeStix/typed-react-form/wiki/FormState)), which you must then pass to all your inputs (this is required for type-checking).
20+
A form always starts with the `useForm` hook call, this function returns a form state manager ([FormState](/docs/FormState)), which you must then pass to all your inputs (this is required for type-checking).
2121

22-
All of the form hook ([`useForm`](https://github.com/CodeStix/typed-react-form/wiki/useForm), [`useChildForm`](https://github.com/CodeStix/typed-react-form/wiki/useChildForm) ...) must be called, unconditionally, at the start of your component, just like the normal React hooks.
22+
All of the form hook ([`useForm`](/docs/useForm), [`useChildForm`](/docs/useChildForm) ...) must be called, unconditionally, at the start of your component, just like the normal React hooks.
2323

2424
✔️ **Importing and using `useForm`**
25+
2526
```jsx
2627
import { useForm } from "typed-react-form";
2728

@@ -36,8 +37,8 @@ function MyForm() {
3637
**typed-react-form** does not expose any submit events or helpers, you must implement your own submitting procedure. This is typically done by using the `<form>` html element with the `onSubmit` event and using a submit button.
3738

3839
✔️ **`<form>` element with `onSubmit` event**
39-
```jsx
4040

41+
```jsx
4142
import { useForm } from "typed-react-form";
4243

4344
function MyForm() {
@@ -52,32 +53,31 @@ function MyForm() {
5253
if (form.error) return;
5354
// form.values contains the modified values, form.defaultValues contains the initial values
5455
console.log("submit", form.values);
55-
}}
56-
>
56+
}}>
5757
<button>Submit!</button>
5858
</form>
5959
);
6060
}
61-
6261
```
6362

6463
You can also just use a `<button>` and submitting in the button's `onClick` handler, but this event does not fire when pressing enter in a text input!
6564

6665
### Creating inputs
6766

68-
This library is build upon the fact that only the things that change should rerender (~refresh), for example: when the *name* field changes, only the inputs that use *name* field will rerender.
67+
This library is build upon the fact that only the things that change should rerender (~refresh), for example: when the _name_ field changes, only the inputs that use _name_ field will rerender.
6968

70-
The built-in form elements ([`FormInput`](https://github.com/CodeStix/typed-react-form/wiki/FormInput), [`FormSelect`](https://github.com/CodeStix/typed-react-form/wiki/FormSelect) ...) implement this by listening for changes only on their specified field. You can also use multiple inputs on the same field (they will the synchronized) and listen for changes on a field by using the [`useListener`](https://github.com/CodeStix/typed-react-form/wiki/useListener) hook or [`Listener`](https://github.com/CodeStix/typed-react-form/wiki/Listener) component.
69+
The built-in form elements ([`FormInput`](/docs/FormInput), [`FormSelect`](/docs/FormSelect) ...) implement this by listening for changes only on their specified field. You can also use multiple inputs on the same field (they will the synchronized) and listen for changes on a field by using the [`useListener`](/docs/useListener) hook or [`Listener`](/docs/Listener) component.
7170

7271
You are now ready to create inputs, this library provides the following built-in components to create type-checked inputs:
7372

74-
- [FormInput](https://github.com/CodeStix/typed-react-form/wiki/FormInput)
75-
- [FormSelect](https://github.com/CodeStix/typed-react-form/wiki/FormSelect)
76-
- [FormTextArea](https://github.com/CodeStix/typed-react-form/wiki/FormTextArea)
73+
- [FormInput](/docs/FormInput)
74+
- [FormSelect](/docs/FormSelect)
75+
- [FormTextArea](/docs/FormTextArea)
7776

78-
**When these inputs do not satisfy your needs**, you can always [create your own](https://github.com/CodeStix/typed-react-form/wiki/Custom-inputs#example-custom-input). These built-in components are just abstractions around hook calls.
77+
**When these inputs do not satisfy your needs**, you can always [create your own](/docs/Custom-inputs#example-custom-input). These built-in components are just abstractions around hook calls.
7978

8079
✔️ **Example type-checked form consisting of 2 fields**
80+
8181
```jsx
8282
// Import FormInput
8383
import { useForm, FormInput } from "typed-react-form";
@@ -99,8 +99,7 @@ function MyForm() {
9999
form.setState({ isSubmitting: false });
100100
// Set new default values if needed
101101
form.setDefaultValues(form.values);
102-
}}
103-
>
102+
}}>
104103
{/* Make sure to pass the form prop! */}
105104
<FormInput form={form} name="email" type="text" />
106105
<FormInput form={form} name="password" type="password" />
@@ -110,51 +109,51 @@ function MyForm() {
110109
}
111110
```
112111

113-
**When you have an object or array field**, you need to *unwrap* this field by using a child/array form. When *unwrapped* you can use the inputs above.
112+
**When you have an object or array field**, you need to _unwrap_ this field by using a child/array form. When _unwrapped_ you can use the inputs above.
114113

115-
- [Object fields](https://github.com/CodeStix/typed-react-form/wiki/Object-fields)
116-
- [Array fields](https://github.com/CodeStix/typed-react-form/wiki/Array-fields)
114+
- [Object fields](/docs/Object-fields)
115+
- [Array fields](/docs/Array-fields)
117116

118117
## Step 3: It's your turn
119118

120119
Tweak the above example to your desire!
121120

122121
**Find your next step here:**
123-
- [Inputs](https://github.com/CodeStix/typed-react-form/wiki/FormInput)
124-
- [Using FormInput, checkboxes, radio buttons](https://github.com/CodeStix/typed-react-form/wiki/FormInput)
125-
- [Using FormTextArea](https://github.com/CodeStix/typed-react-form/wiki/FormTextArea)
126-
- [Using FormSelect](https://github.com/CodeStix/typed-react-form/wiki/FormSelect)
127-
- [Using FormError](https://github.com/CodeStix/typed-react-form/wiki/FormError)
128-
- [Toggling a field using checkbox](https://github.com/CodeStix/typed-react-form/wiki/Toggling-a-field)
129-
- [Example: creating custom inputs like FormInput, FormSelect ...](https://github.com/CodeStix/typed-react-form/wiki/Custom-inputs#example-custom-input)
130-
- [Using Object fields](https://github.com/CodeStix/typed-react-form/wiki/Object-fields)
131-
- [Using Array fields](https://github.com/CodeStix/typed-react-form/wiki/Array-fields)
132-
- [Using validators](https://github.com/CodeStix/typed-react-form/wiki/Validation)
133-
- [Using yup](https://github.com/CodeStix/typed-react-form/wiki/yup)
134-
- [Example: creating a submit button that disables when unmodified/error](https://github.com/CodeStix/typed-react-form/wiki/Custom-inputs#example-form-json-component)
135-
- [Example: creating a component which shows the current form values in JSON](https://github.com/CodeStix/typed-react-form/wiki/Custom-inputs#example-form-json-component)
136-
- [Usage with styled-components](https://github.com/CodeStix/typed-react-form/wiki/Problem-with-styled-components)
137-
- [isSubmitting and custom form state](https://github.com/CodeStix/typed-react-form/wiki/useForm#defaultstate-optional-issubmitting-false)
138122

123+
- [Inputs](/docs/FormInput)
124+
- [Using FormInput, checkboxes, radio buttons](/docs/FormInput)
125+
- [Using FormTextArea](/docs/FormTextArea)
126+
- [Using FormSelect](/docs/FormSelect)
127+
- [Using FormError](/docs/FormError)
128+
- [Toggling a field using checkbox](/docs/Toggling-a-field)
129+
- [Example: creating custom inputs like FormInput, FormSelect ...](/docs/Custom-inputs#example-custom-input)
130+
- [Using Object fields](/docs/Object-fields)
131+
- [Using Array fields](/docs/Array-fields)
132+
- [Using validators](/docs/Validation)
133+
- [Using yup](/docs/yup)
134+
- [Example: creating a submit button that disables when unmodified/error](/docs/Custom-inputs#example-form-json-component)
135+
- [Example: creating a component which shows the current form values in JSON](/docs/Custom-inputs#example-form-json-component)
136+
- [Usage with styled-components](/docs/Problem-with-styled-components)
137+
- [isSubmitting and custom form state](/docs/useForm#defaultstate-optional-issubmitting-false)
139138

140139
## Reference
141140

142-
- Classes
143-
- [FormState](https://github.com/CodeStix/typed-react-form/wiki/FormState)
144-
- [ChildFormState](https://github.com/CodeStix/typed-react-form/wiki/FormState#childformstate)
145-
- Hooks
146-
- [useForm](https://github.com/CodeStix/typed-react-form/wiki/useForm)
147-
- [useChildForm](https://github.com/CodeStix/typed-react-form/wiki/useChildForm)
148-
- [useListener](https://github.com/CodeStix/typed-react-form/wiki/useListener)
149-
- [useAnyListener](https://github.com/CodeStix/typed-react-form/wiki/useAnyListener)
150-
- [useArrayForm](https://github.com/CodeStix/typed-react-form/wiki/useArrayForm)
151-
- Components
152-
- [ChildForm](https://github.com/CodeStix/typed-react-form/wiki/ChildForm)
153-
- [Listener](https://github.com/CodeStix/typed-react-form/wiki/Listener)
154-
- [AnyListener](https://github.com/CodeStix/typed-react-form/wiki/AnyListener)
155-
- [ArrayForm](https://github.com/CodeStix/typed-react-form/wiki/ArrayForm)
156-
- Form element components
157-
- [FormInput](https://github.com/CodeStix/typed-react-form/wiki/FormInput)
158-
- [FormSelect](https://github.com/CodeStix/typed-react-form/wiki/FormSelect)
159-
- [FormTextArea](https://github.com/CodeStix/typed-react-form/wiki/FormTextArea)
160-
- [FormError](https://github.com/CodeStix/typed-react-form/wiki/FormError)
141+
- Classes
142+
- [FormState](/docs/FormState)
143+
- [ChildFormState](/docs/FormState#childformstate)
144+
- Hooks
145+
- [useForm](/docs/useForm)
146+
- [useChildForm](/docs/useChildForm)
147+
- [useListener](/docs/useListener)
148+
- [useAnyListener](/docs/useAnyListener)
149+
- [useArrayForm](/docs/useArrayForm)
150+
- Components
151+
- [ChildForm](/docs/ChildForm)
152+
- [Listener](/docs/Listener)
153+
- [AnyListener](/docs/AnyListener)
154+
- [ArrayForm](/docs/ArrayForm)
155+
- Form element components
156+
- [FormInput](/docs/FormInput)
157+
- [FormSelect](/docs/FormSelect)
158+
- [FormTextArea](/docs/FormTextArea)
159+
- [FormError](/docs/FormError)

articles/Object-fields.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
To be able to create inputs for fields in objects, child form are used. You can create child forms using the `ChildForm` component or `useChildForm` hook.
44

5-
- [useChildForm](https://github.com/CodeStix/typed-react-form/wiki/useChildForm)
6-
- [ChildForm](https://github.com/CodeStix/typed-react-form/wiki/ChildForm)
5+
- [useChildForm](/docs/useChildForm)
6+
- [ChildForm](/docs/ChildForm)
77

88
This design choice makes complete type checking possible.
99

articles/Validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
A validator is a function that takes form values, and returns errors for these values in the same object structure.
44

5-
You can use a validator by passing it to the [`useForm`](https://github.com/CodeStix/typed-react-form/wiki/useForm) hook.
5+
You can use a validator by passing it to the [`useForm`](/docs/useForm) hook.
66

7-
Its it recommended to use a validation library, as this makes the process of validating data mush easier. This library has [built-in support for yup](https://github.com/CodeStix/typed-react-form/wiki/yup).
7+
Its it recommended to use a validation library, as this makes the process of validating data mush easier. This library has [built-in support for yup](/docs/yup).
88

99
## Example
1010

0 commit comments

Comments
 (0)