ES6 Promise

1. What is Promise Promise is a solution for asynchronous programming. It is actually a constructor with its own methods all, reject and resolve, and prototype methods such as then and catch. The Promise object has the following two features: The Promise object represents an asynchronous operation with three states: Read more…

React Markdown(II) – auto generate catalog, support math formula and customize footnotes

Last time, we have introduced how to display a Markdown document in React.(http://52.65.48.177/index.php/2023/03/13/rendering-markdown-in-react/) Now, let’s move forward to support ToC(Table of Content), Mathematical Formula and Footnote. 1. ToC (Table of Content) To support ToC and in-page jump, we need two plugins: remarkToc and rehypeSlug. RehypeSlug is a plugin to add Read more…

Check Form Validation with Yup and Formik

import React, {useEffect} from "react"; import { useFormik } from "formik"; import { Box, Button, FormControl, FormErrorMessage, FormLabel, Heading, Input, Select, Textarea, VStack, } from "@chakra-ui/react"; import * as Yup from 'yup'; import FullScreenSection from "./FullScreenSection"; import useSubmit from "../hooks/useSubmit"; import {useAlertContext} from "../context/alertContext"; const LandingSection = () => { Read more…

An example to show PDF file in React with react-pdf-viewer

Here is an example to show PDF in webpage with React-pdf-viewer, including helpful default layout and loading progress bar. import { Viewer, ProgressBar, Worker } from '@react-pdf-viewer/core'; import { defaultLayoutPlugin } from '@react-pdf-viewer/default-layout'; import '@react-pdf-viewer/core/lib/styles/index.css'; import '@react-pdf-viewer/default-layout/lib/styles/index.css'; const PdfViewer = () => { const defaultLayoutPluginInstance = defaultLayoutPlugin(); return ( <div Read more…

Catalogue