+ styled component + storybook & on top of vite
In this project I would like to re-polish the old school todo list
web app with the latest frontend technology.
They are:
- typescript
- react custom hook style
- styled component
- storybook
-
storybook
npm run storybook
-
mock design system
npm run dev
const foo: FunctionComponent<FooProps> = ({...}) => { return ...}
-
useState
const [todo, setTodo] = useState<string>("");
-
useReducer
const reducer = (state: TodosState, action: TodosAction): TodosState => { ... };
export const AddTodo: FunctionComponent<AddTodoProps> = ({
label = "请输入",
onAddTodo = () => {},
}) => {
const [todo, setTodo] = useState<string>("");
const onChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
setTodo(e.target.value);
};
const onClick = function () {
onAddTodo(todo);
setTodo("");
};
return (
<Div>
<Input type="text" value={todo} placeholder={label} onChange={onChange} />
<Button type="submit" onClick={onClick}>
增加
</Button>
</Div>
);
};
当你想包装另外一个 组件 的 时候 如何去 type props ? 需要一个个列出来吗 ?
type CustomProps = {
foo?: string;
};
function Bar(props: CustomProps & TypeA & Type B) {
...
}