-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
347 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: React常用的内置hooks | ||
lang: zh-CN | ||
feed: | ||
enable: true | ||
description: React常用的内置hooks | ||
--- | ||
|
||
# React常用的内置hooks | ||
|
||
> 本文作者:[onresize](https://github.com/onresize) | ||
[更多参考官方文档](https://zh-hans.react.dev/reference/react/hooks) | ||
|
||
### useState | ||
### useEffect | ||
### useContext | ||
### useReducer | ||
|
||
### useCallback | ||
### useMemo | ||
|
||
### useImperativeHandle | ||
|
||
### useLayoutEffect | ||
### useDebugValue | ||
### useDeferredValue | ||
### useTransition | ||
### useId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--- | ||
title: vite搭建react项目样式隔离方案 | ||
lang: zh-CN | ||
feed: | ||
enable: true | ||
description: vite搭建react项目样式隔离方案 | ||
--- | ||
|
||
# vite搭建react项目样式隔离方案 | ||
|
||
> 本文作者:[onresize](https://github.com/onresize) | ||
### css module方案 | ||
|
||
```js | ||
// vite配置css module | ||
|
||
css: { | ||
modules: { | ||
scopeBehaviour: "global" | "local", | ||
localsConvention: 'camelCaseOnly' // 开启了 camelCase 格式变量名转换(box-left --> boxLeft) | ||
} | ||
} | ||
``` | ||
|
||
```less | ||
// index.module.less | ||
.box { | ||
.box1 {} | ||
} | ||
#box3 {} | ||
``` | ||
|
||
```jsx | ||
// App.jsx | ||
import styles from './index.module.less' | ||
|
||
const App = () => { | ||
return ( | ||
<> | ||
<div classname={`${styles.box} card`}> | ||
<div classname={styles.box1}></div> | ||
</div> | ||
<div id={styles.box3}></div> | ||
</> | ||
) | ||
} | ||
``` | ||
|
||
### css in js方案 | ||
|
||
- #### styled-components | ||
- #### 安装 | ||
|
||
```bash | ||
yarn add styled-components | ||
``` | ||
|
||
- #### 使用 | ||
|
||
```jsx | ||
import styled from 'styled-components'; | ||
|
||
const Wrapper = styled.section` | ||
margin: 0 auto; | ||
width: 300px; | ||
text-align: center; | ||
`; | ||
|
||
const Button = styled.button` | ||
width: 100px; | ||
color: white; | ||
background: skyblue; | ||
`; | ||
|
||
render( | ||
<Wrapper> | ||
<Button>Hello World</Button> | ||
</Wrapper> | ||
); | ||
``` | ||
|
||
- 总结 | ||
|
||
![](/AA_mdPics/css_module.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: 高频面试题 | ||
lang: zh-CN | ||
feed: | ||
enable: true | ||
description: 高频面试题 | ||
--- | ||
|
||
> 本文作者:[onresize](https://github.com/onresize) | ||
- ### Promise终极面试题 | ||
<iframe | ||
src="https://onresize.github.io/react-ts-vite-admin/SandPack?promise1" | ||
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;" | ||
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midipayment; usb; vr; xr-spatial-tracking" | ||
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" | ||
></iframe> | ||
- ### 输出什么 | ||
<iframe | ||
src="https://onresize.github.io/react-ts-vite-admin/SandPack?val1" | ||
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;" | ||
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midipayment; usb; vr; xr-spatial-tracking" | ||
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" | ||
></iframe> |
Oops, something went wrong.