antd

Using setFieldValue onSubmit in Formik

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:35:41
问题 I'm using formik with @jbuschke/formik-antd and react-input-mask . I have a mask +7 (___) ___-__-__ applied to one of the inputs and I need to parse it onSubmit to remove unnecessary symbols. I've defined a const changedValue , which is then used in setFieldValue , but I get the following error: Invariant Violation Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested

Trying to hide the select input and footer elements of Calendar in React

时间秒杀一切 提交于 2019-12-11 04:25:36
问题 I'm working with a DatePicker element in Antd and I'm trying to only show the calendar body. I've tried using styled components to directly target the header and footer of the calendar and set display: none; properties on both, but so far no dice. Antd Library import React from "react"; import ReactDOM from "react-dom"; import "antd/dist/antd.css"; import "./index.css"; import { DatePicker } from "antd"; import styled from "styled-components"; function onChange(value, dateString) { console

Testing if a const modal component is called

大兔子大兔子 提交于 2019-12-11 02:47:50
问题 I have a footer component which has several buttons on it. All of these buttons use the Message const, which is an antd modal : Message.jsx import { Modal } from 'antd'; const { confirm } = Modal; export const Message = (text, okayHandler, cancelHandler) => { confirm({ title: text, okText: 'Yes', cancelText: 'No', onOk: okayHandler, onCancel: cancelHandler, }); }; export default Message; Footer.jsx class Footer extends Component { state = { from: null, redirectToReferrer: false, };

How do I use .babelrc to get babel-plugin-import working for antd?

霸气de小男生 提交于 2019-12-10 02:29:11
问题 I'm new to react, babel, and antd. I installed react and started a project using create-react-app. I installed antd (ant.design). It suggests using babel-plugin-import, so I installed that too. If I interpret it right, the usage documentation for babel-plugin-import says to put this in a .babelrc file: { "plugins": [ ["import", { "libraryName": "antd", "style": true }] ] } I'm having trouble getting it to work. My web console still has the warning: You are using a whole package of antd,

React antd carousel methods

試著忘記壹切 提交于 2019-12-08 17:43:14
问题 I am looking at using the antd Carousel, but I've not seen an example that describes how to use goTo(slideNumber, dontAnimate) method. I have tried to use answers on this question react.js antd carousel with arrows to make goTo method works for me, but it didn't help, I always get carousel ref as null import * as React from 'react'; import { createPortal } from 'react-dom'; import { Modal, Carousel } from 'antd' export default class ImagePreviewCarousel extends React.Component<any, any> {

Overwriting a single (nested) property when extending a React class

一世执手 提交于 2019-12-08 12:02:06
问题 I am rather new to React.js, I believe I understood the major concepts, and I am struggling to find documentation on how to overwrite a single property of a class I am declaring. In on of my components, I define a new class MyColumn based on a class from Ant Design. The architecture (of inheritance rather than composition) was already made by others, and I am not able to change that. import { Table } from "antd"; const { Column } = Table; // ... class MyColumn extends Column<Interfaces

Button hints using antd framework in vscode

别等时光非礼了梦想. 提交于 2019-12-07 14:44:20
问题 I'm using Button and Input of antd in vscode. But It shows error on Button and I want to know why. I have tried Input, and it shows no error. Which is showed in the picture. import React from 'react'; import styles from './index.css'; import router from 'umi/router'; import {Input, Button} from 'antd'; export default function() { const handleClick=()=>{ router.push('/homepage/'); } return ( <div className={styles.normal}> <div className={styles.welcome} /> <h1 className={styles.title}>login<

How to set custom style to antd Select?

徘徊边缘 提交于 2019-12-07 05:37:12
问题 I want to customise antd Select . When a user click on Select the antd Option should display over antd Select instead of displaying beneath the Select antd Select : https://ant.design/components/select/ Expected behaviour: 1 Actual behaviour: 2 JSX import { FaPlane, FaWater } from "react-icons/fa"; //outside of class const shipmentType = { sea: [ { name: "FCL", desc: "FULL CONTAINER LOAD" }, { name: "LCL", desc: "LESS CONTAINER LOAD" } ], air: [{ name: "AIR", desc: "AIR DELIVERY" }] }; /

how to clear antd select items programmatically

断了今生、忘了曾经 提交于 2019-12-07 03:56:02
问题 I'm using https://ant.design/components/select/ How can I programmatically remove the selected items from <Select> ? Note : the <Option> is not a string value, but a Node. 回答1: Just set value to null. e.g. <Select value={null} /> 回答2: Assigning the value of Select to state should work. Try something like this: class Banana extends React.Component { constructor() { super(); this.state = {}; this.handleChange = this.handleChange.bind(this); this.clearSelected = this.clearSelected.bind(this); }

Button hints using antd framework in vscode

孤街浪徒 提交于 2019-12-06 01:42:58
I'm using Button and Input of antd in vscode. But It shows error on Button and I want to know why. I have tried Input, and it shows no error. Which is showed in the picture. import React from 'react'; import styles from './index.css'; import router from 'umi/router'; import {Input, Button} from 'antd'; export default function() { const handleClick=()=>{ router.push('/homepage/'); } return ( <div className={styles.normal}> <div className={styles.welcome} /> <h1 className={styles.title}>login</h1> <ul className={styles.list}> <li><label>username:</label><Input className={styles.input}