@treely/strapi-slices 7.16.0 → 7.16.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treely/strapi-slices",
3
- "version": "7.16.0",
3
+ "version": "7.16.1",
4
4
  "license": "MIT",
5
5
  "author": "Tree.ly FlexCo",
6
6
  "description": "@treely/strapi-slices is a open source library maintained by Tree.ly.",
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
2
  import { render } from '../../test/testUtils';
3
3
  import { mergeDeep } from '../../utils/mergeDeep';
4
- import { redirectSpy } from '../../../__mocks__/next/navigation';
4
+ import { replaceSpy, useRouter } from '../../../__mocks__/next/router';
5
5
  import Redirect from '.';
6
6
  import { RedirectProps } from './Redirect';
7
- import { RedirectType } from 'next/navigation';
8
7
 
9
8
  const defaultProps: RedirectProps = {
10
9
  slice: {
@@ -19,15 +18,13 @@ const setup = (props = {}) => {
19
18
 
20
19
  describe('The Redirect component', () => {
21
20
  afterEach(() => {
22
- redirectSpy.mockRestore();
21
+ replaceSpy.mockRestore();
22
+ useRouter.mockRestore();
23
23
  });
24
24
 
25
25
  it('calls the redirect URL when rendering', () => {
26
26
  setup();
27
27
 
28
- expect(redirectSpy).toHaveBeenCalledWith(
29
- 'https://redirect.com',
30
- RedirectType.replace
31
- );
28
+ expect(replaceSpy).toHaveBeenCalledWith('https://redirect.com');
32
29
  });
33
30
  });
@@ -1,5 +1,5 @@
1
+ import { useRouter } from 'next/router';
1
2
  import React, { useEffect } from 'react';
2
- import { RedirectType, redirect } from 'next/navigation';
3
3
 
4
4
  export interface RedirectProps {
5
5
  slice: {
@@ -8,9 +8,10 @@ export interface RedirectProps {
8
8
  }
9
9
 
10
10
  export const Redirect = ({ slice }: RedirectProps): JSX.Element => {
11
+ const router = useRouter();
11
12
  useEffect(() => {
12
13
  // When using `replace`, the current browser history entry will be replaced
13
- redirect(slice.url, RedirectType.replace);
14
+ router.replace(slice.url);
14
15
  }, [slice.url]);
15
16
 
16
17
  return <></>;