1.0.3 • Published 4 years ago

@midwayjs/next-hooks-compiler v1.0.3

Weekly downloads
7
License
MIT
Repository
github
Last release
4 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

4 years ago

1.0.4-beta.1

4 years ago

1.0.4-beta.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-canary.7

5 years ago

1.0.0-canary.6

5 years ago

1.0.0-canary.4

5 years ago

1.0.0-canary.5

5 years ago

1.0.0-canary.3

5 years ago

1.0.0-canary.2

5 years ago

1.0.0-canary.1

5 years ago

1.0.0-canary.0

5 years ago

0.0.50

5 years ago

0.0.49

5 years ago

0.0.48

5 years ago

0.0.47

5 years ago

0.0.46

5 years ago

0.0.43

5 years ago

0.0.45

5 years ago

0.0.42

5 years ago

0.0.41

5 years ago

0.0.40

5 years ago

0.0.39

5 years ago

0.0.37

5 years ago

0.0.35

5 years ago

0.0.36

5 years ago

0.0.34

5 years ago

0.0.33

5 years ago

0.0.32

5 years ago

0.0.31

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.25

5 years ago