docusaurus
docusaurus copied to clipboard
Non-build ui js using window
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [ ] I have tried the
npm run clearoryarn clearcommand. - [ ] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - [ ] I have tried creating a repro with https://new.docusaurus.io.
- [ ] I have read the console error message carefully (if applicable).
Description
Error:
It looks like you are using code that should run on the client-side only.
To get around it, try using one of:
- <BrowserOnly> (https://docusaurus.io/docs/docusaurus-core/#browseronly)
- ExecutionEnvironment (https://docusaurus.io/docs/docusaurus-core/#executionenvironment).
Reproducible demo
No response
Steps to reproduce
import {api_list, api_user} from "../../util/api"; // use `axios` and `window.atob()`
class Content extends React.Component {
componentDidMount() {
api_list()
api_user().then(response => {
this.setState({})
})
}
}
Expected behavior
build success!
Actual behavior
What am I doing wrong, I can understand not being able to access the window, but I don't think I'm doing anything wrong.
Remove Window for a successful build
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- [ ] I'd be willing to fix this bug myself.
The error message tells you exactly what to do. GH issues are not for support questions; please ask in one of our support channels instead.