Files
medusa-store/www/apps/docs/content/upgrade-guides/medusa-react/4-0-2.md
Shahed Nasser fa7c94b4cc docs: create docs workspace (#5174)
* docs: migrate ui docs to docs universe

* created yarn workspace

* added eslint and tsconfig configurations

* fix eslint configurations

* fixed eslint configurations

* shared tailwind configurations

* added shared ui package

* added more shared components

* migrating more components

* made details components shared

* move InlineCode component

* moved InputText

* moved Loading component

* Moved Modal component

* moved Select components

* Moved Tooltip component

* moved Search components

* moved ColorMode provider

* Moved Notification components and providers

* used icons package

* use UI colors in api-reference

* moved Navbar component

* used Navbar and Search in UI docs

* added Feedback to UI docs

* general enhancements

* fix color mode

* added copy colors file from ui-preset

* added features and enhancements to UI docs

* move Sidebar component and provider

* general fixes and preparations for deployment

* update docusaurus version

* adjusted versions

* fix output directory

* remove rootDirectory property

* fix yarn.lock

* moved code component

* added vale for all docs MD and MDX

* fix tests

* fix vale error

* fix deployment errors

* change ignore commands

* add output directory

* fix docs test

* general fixes

* content fixes

* fix announcement script

* added changeset

* fix vale checks

* added nofilter option

* fix vale error
2023-09-21 20:57:15 +03:00

2.5 KiB

description, sidebar_custom_props
description sidebar_custom_props
Actions Required for v4.0.2
iconName
react

Medusa React: v4.0.2

Version 4.0.2 of Medusa React introduces a new update in its dependencies which can lead to breaking changes.

Overview

Medusa React previously required installing React Query v3 as a peer dependency. This version changes the peer dependency requirement to Tanstack Query - the updated version of React Query.

This requires additional actions related to installing the new dependency and changing imports.


Actions Required

Update Medusa Dependencies

To update to the latest version of Medusa React, run the following command in your custom storefront or admin to update both Medusa React and the core package:

npm install medusa-react@latest @medusajs/medusa@latest

Uninstall React Query v3

As React Query v3 is not required as a peer dependency anymore, uninstall it from your custom storefront or admin:

npm uninstall react-query

Install Tanstack Query

Run the following command to install Tanstack Query:

npm install @tanstack/react-query

Update Imports

Across your custom storefront or admin project, change all imports from react-query to @tanstack/react-query.

For example, update the import for QueryClient where you use it with Medusa Provider:

import { QueryClient } from "@tanstack/react-query"

// this remains the same
const queryClient = new QueryClient()

Fix No QueryClient set Errors

If you're using a Next.js storefront, you might face the following error after this update when you run your storefront:

No QueryClient set

This is due to an issue related to Tanstack Query shipping esm modules in its latest versions and how Next.js uses Webpack.

Although in future versions of medusa-react this issue will be fixed, you can add the following into next.config.js to fix this error:

const path = require("path")

/** @type {import('next').NextConfig} */
const nextConfig = {
  // ... other configs
  webpack: (config, options) => {
    if (options.isServer) {
      config.externals = [
        "@tanstack/react-query", 
        ...config.externals,
      ]
    }
    const reactQuery = path.resolve(
      require.resolve("@tanstack/react-query")
    )
    config.resolve.alias["@tanstack/react-query"] = reactQuery
    return config
  },
}

module.exports = nextConfig