reactiverecord
Advanced tools
Changelog
0.8.11
Fixed a bug that would throw an error when turning off patchMode
.
Changelog
0.8.10
Removed logic which prevented a user_id
attribute from being used in the <Form />
component.
Changelog
0.8.9
The Model.all()
method now accepts an additional options object as an argument. So far, only one option has been implemented called invalidateCache
. When using this option, the existing index will be removed from the store, and will be replaced with the incoming collection returned from the index request. This is useful for situations where reloading a request would result in less records being returned than prior requests, previously resulting in stale records present in the store. To use the invalidateCache
option, pass it in as an object:
News.all({ /* query options */ }, { invalidateCache: true })
The invalidateCache
option will also be used automatically when using the .reload()
method off the <Collection />
component. This will require no additional code, but can also be overridden:
const collectionRef = createRef(null);
...
const handleReload = useCallback(() => {
/* Example usage that would automatically invalidate the cache */
collectionRef.current.reload();
/* Example usage that uses an empty options argument to cancel invalidating the cache */
collectionRef.current.reload({});
}, []);
...
<Collection ref={collectionRef}>
...
<button onClick={handleReload}>Reload</button>
Changelog
0.8.8
Fixed a bug that cause the .reload
method to fail on both <Member />
and <Collection />
.
Changelog
0.8.7
Bug Fix: v0.8.5 introduced a bug that would still run validations even if the input component was disabled
.
Changelog
0.8.5
Validated components will not run validations when the disabled
prop is true
. This is to avoid showing errors near a form field where the user is unable to make a correction.
Changelog
0.8.4
Changelog
0.8.3
Validation Triggers<br>Each validation now accepts an on:
option to control when specific validations occur. This is useful in cases where a specific validation is better to occur when the user is finished typing, rather than as they type. For example, a format validator that validates a ZIP code is in the correct format will validate as the user types, showing an error message before they have completed typing the ZIP code. By adding on: 'BLUR'
to the validation, the format validator will only check on the BLUR event.
The three validation on:
options are:
CHANGE
BLUR
VALIDATE
By using the on:
option, the validation will only occur when a form field triggers the onChange
or onBlur
event, or if the form is being validated as a whole (VALIDATE
), i.e. before form submission.
<Input
{...fields.zip_code}
validators={{
format: [
/* Only validates on blur */
{ with: /\d{5}/, message: 'A ZIP code must have 5 digits.', on: 'BLUR' },
],
/* Validates on all events */
length: [{ maximum: 10, messages: { maximum: 'A ZIP code must be no more than 10 characters.' } }]
}}
/>
The validation trigger may also be an array to support multiple triggers.
format: [
{ with: /\d{5}/, message: 'A ZIP code must have 5 digits.', on: ['BLUR', 'VALIDATE'] },
]
If the validation is to occur for all events, no on:
option is necessary. For the event type, e.g. 'BLUR'
, the case does not matter.
Changelog
0.8.2