Skip to content
/ weact Public

Weact is a Synonym for "weapp react". Supprt Typescript, class style api or react-hooks style api.

Notifications You must be signed in to change notification settings

bgfist/weact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weact

A Framework For Writing Wechat MiniProgram Like React, And With Typescript

install

npm i @bgfist/weact

hook-style

import { FPage, useState, useEffect } from "@bgfist/weact"

function Demo() {
  const [count, setCount] = useState(0)

  useEffect(() => {
    const timer = setTimeout(() => console.log("timer trigger"), count * 1000)
    return () => clearTimeout(timer)
  }, [count])

  const incrCount = () => setCount(count + 1)
  const decrCount = () => setCount(s => s - 1)

  return {
    count, // data
    incrCount, // method
    decrCount, // method
  }
}

FPage(Demo)

for an elegant writing style, weact will group fields and methods for your return using the typeof operator

All supported hooks are listed below, peek their code annotation for a detail explain:

  • useState
  • useEffect
  • useMemo
  • useRef
  • useReducer
  • usePrevious
  • useThisAsPage
  • useThisAsComp
  • ...

debug

import { debugWeact } from "@bgfist/weact"

debugWeact()

About

Weact is a Synonym for "weapp react". Supprt Typescript, class style api or react-hooks style api.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published