This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import "~antd/lib/style/themes/default.less"; | |
| @primary-color: #DC2B1C; | |
| @layout-header-background: #FFE600; | |
| @menu-dark-color: fade(#000, 65%); | |
| @font-size-base: 16px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Form, Button, Input } from 'antd'; | |
| const Example = () => { | |
| const [form] = Form.useForm(); | |
| // Case: Submit button out of Form | |
| const handleFormSubmit = () => { | |
| form.validateFields() | |
| .then((values) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'React' | |
| import { Form, Input, Button } from 'antd'; | |
| import { UserOutlined } from '@ant-design/icons'; | |
| const SubmitButtonInsideForm = () => { | |
| const onFinish = values => { | |
| console.log('Received values of form: ', values); | |
| }; | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect } from 'react'; | |
| import { Form, Button, Input } from 'antd'; | |
| const Example = () => { | |
| const [form] = Form.useForm(); | |
| // Use form inside UseEffect | |
| useEffect(() => { | |
| form.setFieldsValue({ | |
| username: 'Annacoding', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Antd v4 | |
| const Example = () => ( | |
| <Form> | |
| <Form.Item name="username" rules={[{ required: true }]}> | |
| <Input /> | |
| </Form.Item> | |
| </Form> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Antd v3 | |
| const Example = ({ form: { getFieldDecorator } }) => ( | |
| <Form> | |
| <Form.Item> | |
| {getFieldDecorator('annacoding', { | |
| rules: [{ required: true }], | |
| })(<Input />)} | |
| </Form.Item> | |
| </Form> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var getGlobal = function () { | |
| if (typeof self !== 'undefined') { return self; } | |
| if (typeof window !== 'undefined') { return window; } | |
| if (typeof global !== 'undefined') { return global; } | |
| throw new Error('unable to locate global object'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const user = { name: "John" }; | |
| // Fails with `Uncaught TypeError: Cannot read property 'city' of undefined` | |
| const city = user.address.city; | |
| // Works but verbose | |
| let city = "Not Set"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nullValue = null; | |
| const emptyText = ""; // falsy | |
| const someNumber = 42; | |
| const valA = nullValue ?? "default for A"; | |
| const valB = emptyText ?? "default for B"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sitemap: [Sitemap.xml url] | |
| User-agent: * | |
| Allow: /* | |
| Disallow: /api/* |