Open uniquejava opened 5 years ago
官方文档: https://reactjs.org/docs/hooks-intro.html
AND
DAN的博客: A Complete Guide to useEffect
import React, { useState } from 'react';
import t from 'prop-types';
import TextField, { Input } from '@material/react-text-field';
const noop = () => {};
const Holder = ({
itemPrice = 175,
name = '',
email = '',
id = '',
removeHolder = noop,
showRemoveButton = false,
}) => {
const [nameInput, setName] = useState(name);
const [emailInput, setEmail] = useState(email);
const setter = set => e => {
const { target } = e;
const { value } = target;
set(value);
};
return (
<div className="row">
<div className="holder">
<div className="holder-name">
<TextField label="Name">
<Input value={nameInput} onChange={setter(setName)} required />
</TextField>
</div>
<div className="holder-email">
<TextField label="Email">
<Input
value={emailInput}
onChange={setter(setEmail)}
type="email"
required
/>
</TextField>
</div>
{showRemoveButton && (
<button
className="remove-holder"
aria-label="Remove membership"
onClick={e => {
e.preventDefault();
removeHolder(id);
}}
>
×
</button>
)}
</div>
<div className="line-item-price">${itemPrice}</div>
<style jsx>{cssHere}</style>
</div>
);
};
Holder.propTypes = {
name: t.string,
setName: t.func,
email: t.string,
setEmail: t.func,
itemPrice: t.number,
id: t.string,
removeHolder: t.func,
showRemoveButton: t.bool,
};
export default Holder;
https://github.com/facebook/create-react-app
探讨react项目的最佳文件结构
来自medium: Optimal file structure for React applications
关于React-Router v4+ 你所要知道的一切
入口: https://segmentfault.com/a/1190000013894472 英文原文: https://css-tricks.com/react-router-4/
官方文档(贼好): https://reacttraining.com/react-router/web/guides/quick-start
工程结构: 2-3工程目录文件简介
The Complete Introduction to React - All the fundamental React.js concepts in one place
https://jscomplete.com/learn/complete-intro-react