npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kuririn-react-router

v3.0.0

Published

a pages stack library for mobile H5 that can simulate the effect of page stacks in apps (or mini programs), achieve page push, back, and replace, and support browser forward and backward buttons

Downloads

89

Readme

kuririn-react-router 是一个用于 H5 的路由库,它可以模拟 App(或小程序) 中页面栈的效果,实现页面的前进、后退、跳转,支持浏览器的前进、后退按钮

演示

例子中,index 是一级页面,detail1 是 二级页面,detail2 是 三级页面

演示 gif

更加详细的演示代码 example

KRouter

Props

| 属性 | 说明 | 类型 | 是否必填 | 默认值 | | -------------------------- | ------------------------------------------------------ | --------------------- | -------- | --------- | | historyType | 路由方式 | 'hash' \| 'browser' | false | 'browser' | | pages | 全部的页面 | IPageItem[] | true | - | | page404 | 可以传入 404 页面 | | false | - | | lazyLoading | page 懒加载的时候的 loading | React.ReactNode | false | - | | children | 一般用于传入 Tabbar,都是 position fixed 的组件 | React.ReactNode | false | - | | closeDocumentFragmentCache | 是否关闭 page 的文档碎片缓存优化,这个优化默认是开启的 | boolean | false | - |

export interface IPageItem {
  path: string
  title?: string // 可影响 document.title
  component: IPageItemComponent
  isTab?: boolean
}

入口文件App.tsx

import { KRouter } from '@/kuririn-react-router'
import TabBar from '@/TabBar'
import PageDetail1 from '@/pages/detail1/index'
import PageDetail2 from '@/pages/detail2/index'
import PageUserIndex from '@/pages/user/index/index'
import { lazy } from 'react'

const PageIndex = lazy(() => import('@/pages/index/index'))

function App() {
  return (
    <>
      <KRouter
        pages={[
          { path: '/', component: PageIndex, isTab: true },
          { path: '/detail1', component: PageDetail1 },
          { path: '/detail2', component: PageDetail2 },
          { path: '/detail2', component: PageDetail2 },
          { path: '/user', component: PageUserIndex, isTab: true },
        ]}
      >
        <TabBar />
      </KRouter>
    </>
  )
}

export default App

useRouter

import { useRouter } from 'kuririn-react-router'

const router = useRouter()

router.push

router.push('/detail1')

router.back

router.back()
router.back(-1)

router.replace

router.replace('/detail2')

router.switchTab

router.switchTab('/')
router.switchTab('/user')

onPageShow、onPageHide

import { onPageShow, onPageHide } from 'kuririn-react-router'

onPageShow(props, () => {
  console.log('🚀 ~ ', 'index page show')
})

onPageHide(props, () => {
  console.log('🚀 ~ ', 'index page hide')
})