1.0.3 • Published 3 years ago

@midwayjs/next-hooks-compiler v1.0.3

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

@midwayjs/next-hooks-compiler

Midway Hooks compiler

Demo

Compile built-in hooks

source

import { useContext } from '@midwayjs/hooks'

export function useQuery(id: string) {
  const { query } = useContext()
  return query[id] || ''
}

output

export function useQuery(id: string) {
  const _req_ctx = this
  const { query } = _req_ctx.ctx.hooks.useContext()
  return query[id] || ''
}

Compile reference

source

import { useContext } from '@ali/midway-hooks'

export function useQuery(id: string) {
  const { query } = useContext()
  return query[id] || ''
}

export function useResponse() {
  const name = useQuery('hello')
  return name
}

output

export function useQuery(id: string) {
  const _req_ctx = this
  const { query } = _req_ctx.ctx.hooks.useContext()
  return query[id] || ''
}

export function useResponse() {
  const _req_ctx = this
  const name = useQuery.bind(_req_ctx)('hello')
  return name
}
2.0.0-next.0

3 years ago

1.0.4-beta.1

3 years ago

1.0.4-beta.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-canary.7

3 years ago

1.0.0-canary.6

3 years ago

1.0.0-canary.4

3 years ago

1.0.0-canary.5

3 years ago

1.0.0-canary.3

3 years ago

1.0.0-canary.2

3 years ago

1.0.0-canary.1

3 years ago

1.0.0-canary.0

3 years ago

0.0.50

4 years ago

0.0.49

4 years ago

0.0.48

4 years ago

0.0.47

4 years ago

0.0.46

4 years ago

0.0.43

4 years ago

0.0.45

4 years ago

0.0.42

4 years ago

0.0.41

4 years ago

0.0.40

4 years ago

0.0.39

4 years ago

0.0.37

4 years ago

0.0.35

4 years ago

0.0.36

4 years ago

0.0.34

4 years ago

0.0.33

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago

0.0.28

4 years ago

0.0.27

4 years ago

0.0.25

4 years ago