[文章] 深入理解 CSS Grid,写的很详细,文章质量非常的高:https://css-tricks.com/snippets/css/complete-guide-grid/
[文章] Storybook 中文学习教程:https://www.learnstorybook.com/react/zh-CN/get-started
[类库] Axios 支持 React Hooks 调用方式:https://github.com/use-hooks/react-hooks-axios
[类库] Prism 是语法高亮的库:https://github.com/PrismJS/prism
[工具] 可以把 React 组件转换成 Sketch 的层,它是由 Airbnb 公司推出的工具,1.3W Start 了我才了解到:https://github.com/airbnb/react-sketchapp
import React, { useState } from 'react';
import useAxios from '@use-hooks/axios';
export default function App() {
const [gender, setGender] = useState('');
const { response, loading, error, reFetch } = useAxios({
url: `https://randomuser.me/api/${gender === 'unknown' ? 'unknown' : ''}`,
method: 'GET',
options: {
params: { gender },
},
trigger: gender,
// or
// trigger: { gender }
forceDispatchEffect: () => !!gender, // AUTO RUN only if gender is set
});
const { data } = response || {};
const options = [
{ gender: 'female', title: 'Female' },
{ gender: 'male', title: 'Male' },
{ gender: 'unknown', title: 'Unknown' },
];
if (loading) return 'loading...';
return (
<div>
<h2>
DEMO of
<span style={{ color: '#F44336' }}>@use-hooks/axios</span>
</h2>
{options.map(item => (
<div key={item.gender}>
<input
type="radio"
id={item.gender}
value={item.gender}
checked={gender === item.gender}
onChange={e => setGender(e.target.value)}
/>
{item.title}
</div>
))}
<button type="button" onClick={reFetch}>
Refresh
</button>
<div>
{error ? (
error.message || 'error'
) : (
<textarea
cols="100"
rows="30"
defaultValue={JSON.stringify(data || {}, '', 2)}
/>
)}
</div>
</div>
);
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.