Organize the learning notes of React beginner -- component communication
1. Parent child component communication
1) the parent component communicates with the child component, using Props
Parent passes name to child
<GreateH name="kitty"/>
The child component receives the value of the parent component through props and displays
class GreateH extends React.Component{
static defaultProps = {
name:'C ...
Posted by chriskl on Sun, 01 Dec 2019 03:15:21 -0800
A small example of use of react refetch
Source: react design patterns and best practices By Michelle Bertolli Publication time: the first edition in August 2018 (still new)
Use react refetch to simplify the api's code for getting data
const List = ({data: gists}) => {
return (
<ul>
{gists.map(gist => (
<li key={gist.id}>{gist.description}</li& ...
Posted by Norsk.Firefox on Sun, 01 Dec 2019 00:56:29 -0800
The development of cnode website by dva
Complete registration logic and personal center page
1 reg component validation logic
The same validation rules as login
import React , { Component }from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import { Form, Icon, Input, Button, Checkbox,message} from 'antd';
import { routerRedux } from 'dva/router';
const ...
Posted by RyanDev on Sat, 30 Nov 2019 16:58:12 -0800
Component communication of React
Recently, I have nothing to do to learn the React framework by myself. In the process of self-study, all the problems and experiences will be recorded here. I hope that they can help the students who learn the React framework. I don't talk much about the code.First, father to son:
import React, { Component } from 'react';
import Com1 from './co ...
Posted by bassdog65 on Sat, 30 Nov 2019 14:35:09 -0800
How to view the dependency tree of a js, ts file module
Recently, I took over a page of others. The code was messy and jumbled. When I was adding functions, I found that the module I added conflicts with the original module, but I didn't know where the original module was, so I found it.
But I found that this way is too clumsy, and I didn't find the corresponding tool on the Internet, so I wrote a t ...
Posted by Anarking on Sat, 30 Nov 2019 12:43:20 -0800
Use react native tab navigator to switch pages
Switching pages is the most basic function of app. This function needs to be implemented with Navigation components.
RN is developing too fast (v49). The Navigation component that came with it is abandoned. If it is only for ios, it can also be used NavigatorIOS
There are some good ones in the communityhttps://github.com/react-comm ...
Posted by direland on Sat, 30 Nov 2019 11:07:31 -0800
Analysis of Compiler.js module of webpack source code
webpack.js little tail
const webpack = (options, callback) => {
//...
if (callback) {
if (typeof callback !== "function") {
throw new Error("Invalid argument: callback");
}
if (
options.watch === true ||
(Array.isArray(options) && options.some(o => o.watch))
...
Posted by deep on Sat, 30 Nov 2019 11:01:15 -0800
Form form of react+antd series: add and delete
When using antd, what should we do if we want to add and delete forms, as follows:
import { connect } from 'dva';
import { Form, Input, Button } from 'antd';
import styles from './eg1.css';
const FormItem = Form.Item;
function Page(props) {
const { form } = props;
const { getFieldDecorator, getFieldValue } = form
// Form submission
c ...
Posted by jim_de_bo on Sat, 30 Nov 2019 09:29:36 -0800
Four ways to lazy load react components
Lazy load: why?
Solve page fake dead state
Single page vue and react, only one HTML, slow loading of the first screen, fast switching in the later stage, which is not conducive to search engine optimization (SU), and the front-end rendering is not conducive to
500kb for the first screen is good for user experience, and the maxim ...
Posted by feidakila on Thu, 28 Nov 2019 14:18:13 -0800
Practice of installing and using TypeScript in old React projects
Preface
By default, this article gives you an overview of what TypeScript is, mainly explaining how to install and use it in older React projects.
The main purpose of writing this is that there are many online explanations of TypeScript, but they are grammatical concepts or simple examples. There are few articles that actually transform an old ...
Posted by darklight on Wed, 27 Nov 2019 17:42:01 -0800