49文章网www.wz49.cn提供了丰富的唯美、励志、伤感、正能量等经典文章.如果你需要找名人名言、诗词名句、好词好句等,相信在这里能够找到想要的。

fre.js

fre.js

    fre.js - 一个小而美的前端 MVVM 框架

    网站地址:fre.js.org 收录时间:2020年06月03日
    网站人气:366 次所属分类:站长资源
    网站语言:简体中文网站评分:
    百度权重: 搜狗权重:
    网站IP:104.26.8.84 网站编码:UTF-8

fre.js详细介绍

:ghost: Tiny React16 like framework with Concurrent.

:ghost:类似于Concurrent的微小React16框架。

建立状态 代码覆盖率 npm-v npm-d 布罗特利

特征

  • :tada:功能组件和挂钩API
  • :confetti_ball:并发和挂起
  • :telescope:键对帐算法

贡献者

Fre有很棒的代码,我们需要更多加入我们并共同改进。

挂钩API

  • useState

  • useEffect

  • useReducer

  • useLayout

  • useCallback

  • useMemo

  • useRef

  • useContext

useState

useState 是基本API,它将接收初始状态并返回Array

您可以使用它很多次,重新渲染组件时可以使用新状态

function App() { const [up, setUp] = useState(0) const [down, setDown] = useState(0) return ( <div> <h1>{up}</h1>  <button onClick={() => setUp(up + 1)}>+</button>  <h1>{down}</h1>  <button onClick={() => setDown(down - 1)}>-</button>  </div>  ) } 

useReducer

useReduceruseState几乎是相同的,但useReducer需要一个全球性的减速

function reducer(state, action) { switch (action.type) { case 'up': return { count: state.count + 1 } case 'down': return { count: state.count - 1 } } }  function App() { const [state, dispatch] = useReducer(reducer, { count: 1 }) return ( <div> {state.count} <button onClick={() => dispatch({ type: 'up' })}>+</button>  <button onClick={() => dispatch({ type: 'down' })}>+</button>  </div>  ) } 

useEffect

它是效果的执行和清除,由第二个参数表示

useEffect(f)       //  effect (and clean-up) every time useEffect(f, [])   //  effect (and clean-up) only once in a component's life useEffect(f, [x])  //  effect (and clean-up) when property x changes in a component's life 
function App({ flag }) { const [count, setCount] = useState(0) useEffect(() => { document.title = 'count is ' + count }, [flag]) return ( <div> <h1>{count}</h1>  <button onClick={() => setCount(count + 1)}>+</button>  </div>  ) } 

如果返回函数,则该函数可以进行清理:

useEffect(() => { document.title = 'count is ' + count reutn () => { store.unsubscribe() } }, []) 

useLayout

More like useEffect, but useEffect queue in requestAnimationFrame, but useLayout is sync and block commitWork.

useLayout(() => { document.title = 'count is ' + count }, [flag]) 

useMemo

useMemo has the same parameters as useEffect, but useMemo will return a cached value.

function App() { const [count, setCount] = useState(0) const val = useMemo(() => { return new Date() }, [count]) return ( <div> <h1> {count} - {val} </h1>  <button onClick={() => setCount(count + 1)}>+</button>  </div>  ) } 

useCallback

useCallback is based useMemo, it will return a cached function.

const cb = useCallback(() => { console.log('cb was cached') }, []) 


fre.js网站截图

fre.jsAlexa排名

全球排名国家/地区排名趋势本地排名人均PV人均UV
- - - - - -

fre.js域名Whois信息

查询域名:暂无信息
域名注册商:-
域名服务器:-
创建时间:
过期时间:
更新时间:-

fre.js域名备案信息

主办单位名称主办单位性质网站备案/许可证号网站名称网站首页网址审核时间
-- -- -- -- --

fre.js网站SEO信息

网站标题:fre.js - 一个小而美的前端 MVVM 框架
网站关键词 :fre.fre.js.前端框架.
网站描述::ghost: Tiny React16 like framework with Concurrent.

:ghost:类似于Concurrent的微小React16框架。

建立状态 代码覆盖率 npm-v npm-d 布罗特利

特征

  • :tada:功能组件和挂钩API
  • :confetti_ball:并发和挂起
  • :telescope:键对帐算法

贡献者

Fre有很棒的代码,我们需要更多加入我们并共同改进。

挂钩API

  • useState

  • useEffect

  • useReducer

  • useLayout

  • useCallback

  • useMemo

  • useRef

  • useContext

useState

useState 是基本API,它将接收初始状态并返回Array

您可以使用它很多次,重新渲染组件时可以使用新状态

function App() { const [up, setUp] = useState(0) const [down, setDown] = useState(0) return ( <div> <h1>{up}</h1>  <button onClick={() => setUp(up + 1)}>+</button>  <h1>{down}</h1>  <button onClick={() => setDown(down - 1)}>-</button>  </div>  ) } 

useReducer

useReduceruseState几乎是相同的,但useReducer需要一个全球性的减速

function reducer(state, action) { switch (action.type) { case 'up': return { count: state.count + 1 } case 'down': return { count: state.count - 1 } } }  function App() { const [state, dispatch] = useReducer(reducer, { count: 1 }) return ( <div> {state.count} <button onClick={() => dispatch({ type: 'up' })}>+</button>  <button onClick={() => dispatch({ type: 'down' })}>+</button>  </div>  ) } 

useEffect

它是效果的执行和清除,由第二个参数表示

useEffect(f)       //  effect (and clean-up) every time useEffect(f, [])   //  effect (and clean-up) only once in a component's life useEffect(f, [x])  //  effect (and clean-up) when property x changes in a component's life 
function App({ flag }) { const [count, setCount] = useState(0) useEffect(() => { document.title = 'count is ' + count }, [flag]) return ( <div> <h1>{count}</h1>  <button onClick={() => setCount(count + 1)}>+</button>  </div>  ) } 

如果返回函数,则该函数可以进行清理:

useEffect(() => { document.title = 'count is ' + count reutn () => { store.unsubscribe() } }, []) 

useLayout

More like useEffect, but useEffect queue in requestAnimationFrame, but useLayout is sync and block commitWork.

useLayout(() => { document.title = 'count is ' + count }, [flag]) 

useMemo

useMemo has the same parameters as useEffect, but useMemo will return a cached value.

function App() { const [count, setCount] = useState(0) const val = useMemo(() => { return new Date() }, [count]) return ( <div> <h1> {count} - {val} </h1>  <button onClick={() => setCount(count + 1)}>+</button>  </div>  ) } 

useCallback

useCallback is based useMemo, it will return a cached function.

const cb = useCallback(() => { console.log('cb was cached') }, []) 


与fre.js相关推荐

网络科技

猜你喜欢

最近更新

关注我们

qrcode

49文章网提供了丰富的唯美、励志、伤感、正能量等经典文章.如果你需要找名人名言、诗词名句、好词好句等,相信在这里能够找到想要的.