webpack官方文档目前对chunks对设置为各个值对打包的影响解释的较少,下面大部分内容是来自
webpack-4-splitchunks-plugin https://medium.com/dailyjs/webpack-4-splitchunks-plugin-d9fbbe091fd0
以及基于webpack 4.43.0实验结论
webpack官方文档目前对chunks对设置为各个值对打包的影响解释的较少,下面大部分内容是来自
webpack-4-splitchunks-plugin https://medium.com/dailyjs/webpack-4-splitchunks-plugin-d9fbbe091fd0
以及基于webpack 4.43.0实验结论
| export default ({ onChange, sessionId }) => { | |
| const onChangeStablize = useStableCallback(onChange) | |
| useEffect(() => { | |
| fetch(`/api/v1/session/${sessionId}`) | |
| .then(async (response) => { | |
| if (response.status === 200) { | |
| const data = await response.json() | |
| onChangeStablize(data) | |
| } | |
| }) |
| const [page, setPage] = useState({ pageCurrent: 1, pageTotal: 1 }) | |
| // The reference of page will change only when the value of pageCurrent or pageTotal changes. | |
| const semaPage = useSemantic(page) | |
| ... |
| export default () => { | |
| const [state, setState] = useState({ | |
| foo: 0, | |
| bar: 1, | |
| }) | |
| const foo = state.foo | |
| useEffect(() => { | |
| ...do something with foo... |
| const cb = useCallback((a) => { | |
| //use dep a | |
| ... | |
| return (b) => { | |
| // use dep b | |
| ... | |
| } | |
| }, []) |
| const fetchProduct = async (productId) => { | |
| const response = await fetch('http://myapi/product' + productId); // Uses productId prop | |
| const json = await response.json() | |
| return json | |
| } | |
| function ProductPage({ productId }) { | |
| const [product, setProduct] = useState(null) | |
| useEffect(() => { |
| function ProductPage({ productId }) { | |
| const [product, setProduct] = useState(null) | |
| const fetchProduct = useCallback(async (productId) => { | |
| const response = await fetch('http://myapi/product' + productId); // Uses productId prop | |
| const json = await response.json() | |
| setProduct(json) | |
| }, []) | |
| useEffect(() => { |
| function ProductPage({ productId }) { | |
| const [product, setProduct] = useState(null) | |
| async function fetchProduct () { | |
| const response = await fetch('http://myapi/product' + productId); // Uses productId prop | |
| const json = await response.json() | |
| setProduct(json) | |
| }) | |
| useEffect(() => { |
| const obj1 = { | |
| name: 'jack' | |
| } | |
| const obj2 = { | |
| name: 'jack' | |
| } | |
| const str1 = 'jack' | |
| const str2 = 'jack' |
| export default ({ onDataUpdate, id }) => { | |
| useEffect(() => { | |
| fetch(`/api/v1/session/${id}`) | |
| .then((res) => { | |
| onDataUpdate(res) | |
| }) | |
| }, [onDataUpdate, id]) | |
| } |