How to use the piral-core.compare function in piral-core

To help you get started, we’ve selected a few piral-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smapiot / piral / src / packages / piral-inferno / src / create.ts View on Github external
shouldComponentUpdate(nextProps: ExtensionSlotProps) {
      return !compare(this.props, nextProps);
    }
github smapiot / piral / src / packages / piral-preact / src / create.ts View on Github external
shouldComponentUpdate(nextProps: ExtensionSlotProps) {
      return !compare(this.props, nextProps);
    }
github smapiot / piral / src / packages / piral-forms / src / useForm.ts View on Github external
function updateData(
  id: string,
  state: FormDataState,
  updateState: StateUpdater,
  newData: TFormData,
  options: InputFormOptions,
) {
  const { onChange } = options;
  updateState(id, state, {
    currentData: newData,
    changed: !compare(newData, state.initialData),
    error: undefined,
  });

  if (isfunc(onChange)) {
    Promise.resolve(onChange(newData))
      .then(data => {
        const updatedData = { ...newData, ...data };
        updateState(id, state, {
          currentData: updatedData,
          changed: !compare(updatedData, state.initialData),
          error: undefined,
        });
      })
      .catch(error =>
        updateState(id, state, {
          error,
github smapiot / piral / src / packages / piral-forms / src / useForm.ts View on Github external
.then(data => {
        const updatedData = { ...newData, ...data };
        updateState(id, state, {
          currentData: updatedData,
          changed: !compare(updatedData, state.initialData),
          error: undefined,
        });
      })
      .catch(error =>