Skip to content

Releases: TheEdoRan/next-safe-action

v7.9.6

22 Oct 14:10
2e1fe62
Compare
Choose a tag to compare

7.9.6 (2024-10-22)

Bug Fixes

  • validation-errors: type inference for branded, nullable, optional and array types (#284) (2e1fe62)

v7.9.5

21 Oct 15:47
f8519cc
Compare
Choose a tag to compare

7.9.5 (2024-10-21)

Refactors

v7.9.4

12 Oct 13:58
45e0f96
Compare
Choose a tag to compare

7.9.4 (2024-10-12)

Refactors

  • hooks: deprecate executeOnMount (45e0f96)

v7.9.3

13 Sep 13:49
197ec51
Compare
Choose a tag to compare

7.9.3 (2024-09-13)

Bug Fixes

v7.9.3-beta.1

13 Sep 13:43
d2d7bdd
Compare
Choose a tag to compare
v7.9.3-beta.1 Pre-release
Pre-release

7.9.3-beta.1 (2024-09-13)

Bug Fixes

v7.9.2

08 Sep 17:21
a789d0a
Compare
Choose a tag to compare

7.9.2 (2024-09-08)

Refactors

  • pass utils to validation errors shape customizer functions (#263) (a789d0a), closes #256

v7.9.1

08 Sep 01:06
3d32f9d
Compare
Choose a tag to compare

7.9.1 (2024-09-08)

Refactors

  • remove additional fetchError prop from hook return object (#262) (3d32f9d)

v7.9.1-beta.1

07 Sep 23:27
d8a3352
Compare
Choose a tag to compare
v7.9.1-beta.1 Pre-release
Pre-release

7.9.1-beta.1 (2024-09-07)

Refactors

  • remove additional fetchError prop from hook return object (d8a3352)

v7.9.0

04 Sep 12:31
c900720
Compare
Choose a tag to compare

7.9.0 (2024-09-04)

Features

  • merge server error handling functions into handleServerError (#257) (c900720)

Description

v7.9.0 merges the functionality of handleServerErrorLog and handleReturnedServerError functions into a single optional initialization function called handleServerError. This change has been made because having two functions for server error handling is unnecessary, you can easily manage both logging and returned error within a single function.

Upgrade guide

Suppose you have this code using next-safe-action < 7.9.0:

import { createSafeActionClient } from "next-safe-action";

const actionClient = createSafeActionClient({
  // handles logging
  handleServerErrorLog(error) {
    console.error("my custom error log:", error.message);
  },
  // handles returned shape
  handleReturnedServerError(error) {
    return {
      message: error.message,
    };
  },
});

With next-safe-action >= 7.9.0 it becomes:

import { createSafeActionClient } from "next-safe-action";

const ac = createSafeActionClient({
  // handles both logging and returned shape
  handleServerError(error) {
    console.error("my custom error log:", error.message);
    return {
      message: error.message,
    };
  },
});

So, minimal refactoring is required, and the action client creation is cleaner this way.


Note

Even if you want to change just the logging mechanism, you still have to return an error shape from handleServerError, otherwise the resulting type would be void.

So, if you want for instance keep the default error message as the returned server error and just update the console logging, you can do it like this:

import { createSafeActionClient, DEFAULT_SERVER_ERROR_MESSAGE } from "next-safe-action";

const ac = createSafeActionClient({
  handleServerError(error) {
    console.error("my custom error log:", error.message);
    return DEFAULT_SERVER_ERROR_MESSAGE;
  },
});

v7.8.2

02 Sep 19:46
8e654bc
Compare
Choose a tag to compare

7.8.2 (2024-09-02)

Documentation

  • update library description (8e654bc)