react-icons/fa APIs
- FaTwitter
- FaGithub
- FaInstagram
- FaLinkedin
- FaTimes
- FaPlus
- FaFacebookF
- FaSearch
- FaYoutube
- FaFacebook
- FaTrash
- FaHeart
- FaLinkedinIn
- FaBars
- FaEnvelope
- FaStar
- FaPlay
- FaHome
- FaEdit
- FaSun
- FaMoon
- FaUser
- FaGithubAlt
- FaFacebookSquare
- FaArrowRight
- FaCheck
- FaTwitterSquare
- FaAngleRight
- FaInfoCircle
- FaMapMarkerAlt
- FaArrowLeft
- FaPen
- FaTrashAlt
- FaShoppingCart
- FaGithubSquare
- FaCheckCircle
- FaDownload
- FaCaretDown
- FaChevronRight
- FaCog
- FaCode
- FaDev
- FaDribbble
- FaLocationArrow
- FaExternalLinkAlt
- FaAngleDown
- FaArrowUp
- FaSignOutAlt
- FaTags
- FaQuoteLeft
- FaPause
- FaChevronLeft
- FaChevronDown
- FaReact
- FaFolderOpen
- FaCircle
- FaAngleLeft
- FaCompass
- FaAlignRight
- FaMinus
- FaBoxOpen
- FaLink
- FaUsers
- FaGoogle
- FaTwitch
- FaRss
- FaSpotify
- FaCrown
- FaLock
- FaCopyright
- FaRegTrashAlt
- FaUserAlt
- FaRegStar
- FaPhone
- FaMapMarkedAlt
- FaRegCircle
- FaVolumeUp
- FaDiscord
- FaUserCircle
- FaList
- FaStackOverflow
- FaFreeCodeCamp
- FaMicrophone
- FaRedo
- FaClipboard
- FaChevronUp
- FaLongArrowAltRight
- FaAngleDoubleRight
- FaKey
- FaCubes
- FaBan
- FaMediumM
- FaPinterest
- FaVideo
- FaDribbbleSquare
- FaComment
- FaBellSlash
- FaRegBuilding
- FaSlack
- FaItunesNote
- FaBox
- FaWonSign
- FaAirbnb
- FaDoorOpen
- FaGlobe
- FaBath
- FaParking
- FaWhatsapp
- FaUserInjured
- FaRegPlusSquare
- FaPlayCircle
- FaPauseCircle
- FaVolumeMute
- FaSpinner
- FaRegLightbulb
- FaCcVisa
- FaCcMastercard
- FaCcPaypal
- FaCcAmazonPay
- FaRegHeart
- FaCartArrowDown
- FaCartPlus
- FaPinterestSquare
- FaPaypal
- FaAmazon
- FaShopify
- FaApple
- FaTruck
- FaUndoAlt
- FaRocketchat
- FaWallet
- FaPinterestP
- FaGooglePlay
- FaCaretUp
- FaFilter
- FaCalendarAlt
- FaCodeBranch
- FaExclamationCircle
- FaEye
- FaOsi
- FaRegEdit
- FaMicrophoneAlt
- FaMicrophoneAltSlash
- FaCogs
- FaEllipsisH
- FaEquals
- FaQrcode
- FaAddressBook
- FaServer
- FaFolder
- FaLongArrowAltLeft
- FaSkype
- FaHandHoldingHeart
- FaRegPaperPlane
- FaRegBookmark
- FaInbox
- FaHamburger
- FaSearchLocation
- FaBirthdayCake
- FaUserGraduate
- FaGoogleDrive
- FaPaperPlane
- FaLockOpen
- FaUserFriends
- FaExchangeAlt
- FaEllipsisV
- FaSortAmountDown
- FaSortAmountUp
- FaCaretSquareRight
- FaCaretSquareLeft
- FaColumns
- FaUndo
- FaQuestionCircle
- FaBloggerB
- FaRedditAlien
- FaCodepen
- FaGitlab
- FaBlogger
- FaCameraRetro
- FaTabletAlt
- FaRegNewspaper
- FaRegCalendarAlt
- FaForward
- FaQuoteRight
- FaVoteYea
- FaShareSquare
- FaBehanceSquare
- FaSignInAlt
- FaSkull
- FaReddit
- FaRegSmileBeam
- FaWindowClose
- FaWindowMinimize
- FaWindowMaximize
- FaPaste
- FaStopwatch
- FaStop
- FaSave
- FaFileExport
- FaHandPointer
- FaFile
- FaMapSigns
- FaClipboardCheck
- FaClock
- FaThList
- FaDumbbell
- FaGuitar
- FaNetworkWired
- FaPuzzlePiece
- FaUserEdit
- FaEyeSlash
- FaPhoneAlt
- FaStickyNote
- FaThumbsUp
- FaThumbsDown
- FaArrowCircleUp
- FaLightbulb
- FaBookOpen
- FaRegSquare
- FaItalic
- FaBold
- FaPencilAlt
- FaSlash
- FaShapes
- FaShip
- FaTree
- FaFilePdf
- FaRegArrowAltCircleRight
- FaFileUpload
- FaKeyboard
- FaBehance
- FaGoodreadsG
- FaProductHunt
- FaXing
- FaBolt
OtherRelated APIs
react-icons/fa#FaExchangeAlt JavaScript Examples
The following examples show how to use
react-icons/fa#FaExchangeAlt.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatePicker.js From dm2 with Apache License 2.0 | 4 votes |
DatePicker = ({
size,
value,
selectRange = false,
showTime = false,
dateFormat = "MM.dd.yyyy",
timeFormat = "HH:mm",
onChange,
}) => {
const finalFormat = showTime ? `${dateFormat} ${timeFormat}` : dateFormat;
/**@type {import("react").RefObject<DP>} */
const datepickerRef = useRef();
const dropdownRef = useRef();
const formatDate = (date) => {
if (!isDefined(date)) return "";
const parsedDate = new Date(date === null ? Date.now() : date);
if (isValid(parsedDate)) {
return format(parsedDate, finalFormat);
}
return "";
};
const [initialStartDate, initialEndDate] = selectRange
? value
: [].concat(value);
const [realStartDate, setRealStartDate] = useState(initialStartDate ?? null);
const [realEndDate, setRealEndDate] = useState(initialEndDate ?? null);
const [startDate, setStartDate] = useState(formatDate(realStartDate));
const [endDate, setEndDate] = useState(formatDate(realEndDate));
const updateDate = (date, dateSetter, realDateSetter) => {
if (date.length > finalFormat.length) return;
dateSetter?.(date);
if (isDefined(date) && isMatch(date, finalFormat) && date.length === finalFormat.length) {
const realDate = new Date(date || null);
if (isValid(realDate)) realDateSetter?.(realDate);
}
};
const dateRange = useMemo(
() =>
selectRange
? {
startDate: realStartDate,
endDate: realEndDate,
}
: {},
[selectRange, realStartDate, realEndDate],
);
useEffect(() => {
if (isValid(realStartDate)) setStartDate(formatDate(realStartDate));
}, [realStartDate]);
useEffect(() => {
if (isValid(realEndDate)) setEndDate(formatDate(realEndDate));
}, [realEndDate]);
useEffect(() => {
if (selectRange) {
onChange?.([realStartDate, realEndDate]);
} else if (realStartDate) {
onChange?.(realStartDate);
}
}, [realStartDate, realEndDate]);
const onChangeHandler = useCallback((date) => {
if (realStartDate !== null && realEndDate === null && selectRange) {
setRealEndDate(date);
dropdownRef.current?.close();
} else {
setRealStartDate(date);
if (selectRange) {
setRealEndDate(null);
} else {
dropdownRef.current?.close();
}
}
});
return (
<Block name="datepicker">
<Dropdown.Trigger
ref={dropdownRef}
toggle={false}
content={(
<DP
{...dateRange}
ref={datepickerRef}
selected={realStartDate}
onChange={(date) => onChangeHandler(date)}
onSelect={(date) => onChangeHandler(date)}
monthsShown={2}
selectsRange={selectRange}
showTimeSelect={showTime}
inline
/>
)}
>
<Elem name="output" mod={{ range: selectRange }}>
<Input
size={size}
value={startDate || ""}
onChange={(e) =>
updateDate(e.target.value, setStartDate, setRealStartDate)
}
/>
{selectRange && (
<>
<Elem name="separator">
<Icon icon={FaExchangeAlt} />
</Elem>
<Input
size={size}
value={endDate || ""}
onChange={(e) =>
updateDate(e.target.value, setEndDate, setRealEndDate)
}
/>
</>
)}
</Elem>
</Dropdown.Trigger>
</Block>
);
}