I'm currently facing an issue when using @rive-app/react-canvas in a ReactJS Module Federation setup (Webpack as host and Vite as remote)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, typescript, vite, webpack
- Domain
- frontend
Research direction
Compare the host webpack.config.js and remote vite.config.ts federation settings, then inspect the exposed src/AppRemote.tsx path and the useRive stack shown in the error. Reproduce the Webpack-host/Vite-remote setup with @rive-app/react-canvas and verify that the remote component loads without the null useState runtime error.
Written by the indexing model from the issue text.
Description
Hi, I'm encountering a problem when trying to use @rive-app/react-canvas in a micro-frontend architecture where the host application is built with Webpack and the remote module is built with Vite. Here's a brief overview of my setup:
Webpack (Host) – webpack.config.js:
new ModuleFederationPlugin({
name: "webpackHost",
filename: "remoteEntry.js",
remotes: {
"@herond-point": "promise import("http://localhost:3001/assets/remoteEntry.js")",
},
shared: {
react: {
eager: true,
import: "react",
shareKey: "react",
shareScope: "default",
singleton: true,
},
"react-dom": {
eager: true,
import: "react-dom",
shareKey: "react-dom",
shareScope: "default",
singleton: true,
},
},
})
Vite (Remote) – vite.config.ts:
optimizeDeps: {
include: ['@radix-ui/react-primitive', '@radix-ui/themes', 'react-redux', '@reduxjs/toolkit'],
},
build: {
modulePreload: false,
target: 'esnext',
minify: false,
cssCodeSplit: false,
rollupOptions: {
output: {
minifyInternalExports: false,
assetFileNames: (assetInfo) => {
const ext = assetInfo.name?.split('.').pop();
if (ext === 'svg') {
return 'assets/icons/[name]-[hash][extname]';
}
return 'assets/[name]-[hash][extname]';
},
},
},
},
publicDir: 'dist',
plugins: [
react({ plugins: [['@swc/plugin-styled-components', {}]] }),
macros(),
svgr(),
tsconfigPaths(),
federation({
name: '@herond-point',
filename: 'remoteEntry.js',
exposes: {
'./app': './src/AppRemote.tsx',
},
shared: {
react: { requiredVersion: dependencies['react'] },
'react-dom': { requiredVersion: dependencies['react-dom'] },
},
}),
]
Error Details:
When loading a remote component that uses @rive-app/react-canvas, I receive the following runtime error in the browser console:
herond_point.bundle.js:2
TypeError: Cannot read properties of null (reading 'useState')
at react_production_min.useState (index-B1oEREHO.js:262:21)
at Object.O [as useRive] (index-BQu3j2DS.js:7128:16)
at MysteryPotReward (index-BQu3j2DS.js:7265:19)
at gi (herond_point.bundle.js:2:128737)
at ws (herond_point.bundle.js:2:187678)
at vu (herond_point.bundle.js:2:176930)
at _u (herond_point.bundle.js:2:176858)
at gu (herond_point.bundle.js:2:176721)
at su (herond_point.bundle.js:2:173883)
at jo (herond_point.bundle.js:2:115113)
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 58
- Avg merge
- 3h 23m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rive-app/rive-react
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
rive-app/rive-react#440 · 5 comments · 4 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
rive-app/rive-react#410 · 1 comment ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 42/100
rive-app/rive-react#409 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
rive-app/rive-react#400 ·
-
triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
rive-app/rive-react#392 ·
All issues in rive-app/rive-react
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·