I'm trying to create the most basic react app using antd but it renders a blank page. I used a venv, ran npx create-react-app .
and replaced the default App.js file contents with the below example from the antd website. Can someone please advise?
App.js:
import React from 'react';
import { Button } from 'antd';
import 'antd/dist/reset.css';
import './App.css';
const App = () => (
<div className="App">
<Button type="primary">Button</Button>
</div>
);
export default App;
Terminal output:
Compiled successfully!
You can now view antd-examples in the browser.
Local: http://localhost:3000
On Your Network: http://10.5.0.2:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
webpack compiled successfully
I was expecting to see a button show up with the above code given there were no errors or warnings but just saw a blank screen instead. Note that when I use the starter code generated from running npx create-react-app .
the page renders fine and I see the slowly rotating react symbol.
Edit:
- There is some messages in the console log. You can see it here in pastebin.
- The package.json file contents are here on pastebin.
CodePudding user response:
The problem in this case is that the antd
dependency is missing in the package.json
. After installing it with yarn add antd
the code works like expected.