1.0.10 • Published 3 years ago

@ronin-react/react-keep-alive v1.0.10

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

Usage

install

yarn add @ronin-react/react-keep-alive

import component

import {useState} from 'react'
import {KeepScope, KeepAlive} from '@ronin-react/react-keep-alive'

const ids = [Math.random().toString(36).slice(2), Math.random().toString(36).slice(2)]

const MyComponent = () => {
	const [num, setNum] = useState(0)
	return <>
		<button onClick={() => setNum(num === 0 ? 1 : 0)}>
		 click to varify
		</button>
		{num === 0 && <KeepAlive id={ids[0]}>
		  <div>{Math.random()}</div>
		 </KeepAlive>}
		 {num === 1 && <KeepAlive id={ids[1]}>
		  <div>{Math.random()}</div>
		 </KeepAlive>}
		</>
}

const App = () => {
	retutn <KeepScope><MyComponent /></KeepScope>	
}

hook

useRefreshModule: (modulename: string) => () => void

import {useRefreshModule} from '@ronin-react/react-keep-alive'

const MyComponent = () => {
	const fresh = useRefreshModule('otherModule')
	return <div onClick={fresh}></div>
}
1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

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