Closed putrairawan992 closed 4 years ago
Hey @putrairawan992
This happens because you didn't wrap the app with a Router from react-router-dom
.
I added an example of how to do that by creating a file in src/gatsby-theme-docz/wrapper.js
that wraps the page with a MemoryRouter.
Try it out in a new app :
yarn create docz-app react-router-docz-app --example react-router
cd react-router-docz-app
yarn docz dev
Or in your app create a file called wrapper.js
in src/gatsby-theme-docz/
and add the following code in it :
import React from "react";
import { MemoryRouter } from "react-router-dom";
export default ({ children }) => {
return <MemoryRouter>{children}</MemoryRouter>;
};
Hope that helps !
if for my code above, where should I put the memory router?
Code above remains as is.
In your codebase, add a file src/gatsby-theme-docz/wrapper.js
and inside it, use the memory router.
then how do you use it?
🤔 docz
should detect it automatically. Which version of docz
are you using ?
Do I have to upgrade?
Ok, so you're on v1.
You don't have to upgrade to v2 if you're not ready.
You should use the wrapper
field in the docz
config : http://docz-v1.surge.sh/docs/project-configuration#wrapper
In your doczrc.js
add wrapper: 'src/gatsby-theme-docz/wrapper'
:
export default {
+ wrapper: 'src/gatsby-theme-docz/wrapper',
}
const path = require('path'); const fs = require('fs'); const lessToJs = require('less-vars-to-js'); const themeVariables = lessToJs(fs.readFileSync(path.join(__dirname, './src/antd-config/antdThemeVars.less'), 'utf8'));
export default { title: 'ECOMMERCE', wrapper: './src/gatsby-theme-docz/wrapper', modifyBundlerConfig: (config) => { config.resolve.extensions.push('.sass') config.resolve.extensions.push('.css') config.module.rules.push({ test: /.sass$/, use: [ "style-loader", "css-loader", "sass-loader", { loader: 'sass-resources-loader', options: { resources: './src/sass/variable.sass' }, } ] }) config.module.rules.push({ test: /.css$/, use: ["style-loader", "css-loader", "sass-loader"] }) config.module.rules.push({ test: /.less$/, use: [ 'style-loader', 'css-loader', { loader: "less-loader", options: { javascriptEnabled: true, modifyVars: themeVariables } } ] }) return config }, notUseSpecifiers: true, filterComponents: files => files.filter(filepath => /w*.(js|jsx|ts|tsx)$/.test(filepath)) }
still error
@putrairawan992 That error is not the same error. If you check the error messages it is a different error and I think this new error you have has more to do with react-router
and how react router Link
is supposed to be used and not so much linked to docz
.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bug Report
Describe the bug if I use the link from react-router-dom there is an error like the screanshoot below, but if I use a normal href,
A clear and concise description of what the bug is. please help, the solution is how can you use the Link from react-router-dom?
To Reproduce this my code
and this file index.md :
name: Breadcrumbs menu: Components
In order to allow us to quickly reproduce you issue please include a link to a reproduction repository.
Expected behavior
A clear and concise description of what you expected to happen..
Environment
Additional context/Screenshots