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 debounce from 'lodash/debounce' // Or throttle | |
| export const HelloWorld: React.FC = () => { | |
| // Example for a state can change quickly in a bit of time | |
| const [innerParams, setInnerParams] = React.useState<string>('') | |
| // Use ref to create a freeze debounce function to make sure it's not rerender | |
| // Need to pass the changing parameters here | |
| const fetch = React.useRef(debounce((params: any) => { |
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
| /* | |
| Before Septemper 15 2018, Vietnam has phone number start with 09*, 01(2|6|8|9). | |
| After that, the phone number can start with 03, 05, 07 or 08. | |
| So this function provide a way to validate the input number is a Vietnamese phone number | |
| */ | |
| function isVietnamesePhoneNumber(number) { | |
| return /(03|05|07|08|09|01[2|6|8|9])+([0-9]{8})\b/.test(number); | |
| } |