-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Feat: support keepalive without experimental version of react (#6768)
* feat: support keepalive without experimental version of react * feat: add keep alive example * fix: optimize code
- v3.5.0
- rax-compat@0.3.0
- rax-compat@0.2.12
- rax-compat@0.2.11
- @ice/webpack-config@1.1.16
- @ice/webpack-config@1.1.15
- @ice/webpack-config@1.1.14
- @ice/webpack-config@1.1.13
- @ice/webpack-config@1.1.12
- @ice/webpack-config@1.1.11
- @ice/style-import@1.1.0
- @ice/shared-config@1.2.9
- @ice/shared-config@1.2.8
- @ice/shared-config@1.2.7
- @ice/shared-config@1.2.6
- @ice/shared-config@1.2.5
- @ice/shared-config@1.2.4
- @ice/runtime@1.5.1
- @ice/runtime@1.4.13
- @ice/runtime@1.4.11
- @ice/runtime@1.4.10
- @ice/runtime@1.4.9
- @ice/runtime@1.4.8
- @ice/runtime@1.4.7
- @ice/runtime@1.4.6
- @ice/runtime@1.4.5
- @ice/runtime@1.4.4
- @ice/runtime@1.4.3
- @ice/runtime@1.4.2
- @ice/rspack-config@1.2.1
- @ice/rspack-config@1.1.10
- @ice/rspack-config@1.1.9
- @ice/rspack-config@1.1.8
- @ice/rspack-config@1.1.7
- @ice/rspack-config@1.1.6
- @ice/rspack-config@1.1.5
- @ice/rspack-config@1.1.4
- @ice/plugin-unocss@1.1.0
- @ice/plugin-stream-error@1.0.2
- @ice/plugin-stream-error@1.0.1
- @ice/plugin-request@1.0.3
- @ice/plugin-rax-compat@0.3.2
- @ice/plugin-rax-compat@0.3.1
- @ice/plugin-miniapp@1.2.1
- @ice/plugin-jsx-plus@1.0.4
- @ice/plugin-intl@1.1.0
- @ice/plugin-intl@1.0.2
- @ice/plugin-intl@1.0.1
- @ice/plugin-i18n@5.0.1
- @ice/plugin-fusion@1.1.0
- @ice/miniapp-runtime@1.2.1
- @ice/miniapp-react-dom@1.1.1
- @ice/jsx-runtime@0.3.1
- @ice/jsx-runtime@0.3.0
- @ice/bundles@0.2.7
- @ice/bundles@0.2.6
- @ice/bundles@0.2.5
- @ice/bundles@0.2.4
- @ice/app@3.5.1
- @ice/app@3.5.0
- @ice/app@3.4.12
- @ice/app@3.4.11
- @ice/app@3.4.10
- @ice/app@3.4.9
- @ice/app@3.4.8
- @ice/app@3.4.7
- @ice/app@3.4.6
- @ice/app@3.4.5
- @ice/app@3.4.4
Showing
24 changed files
with
254 additions
and
40 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineConfig } from '@ice/app'; | ||
|
||
export default defineConfig(() => ({})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@examples/with-keep-alive-react", | ||
"private": true, | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "ice start", | ||
"build": "ice build" | ||
}, | ||
"dependencies": { | ||
"react": "0.0.0-experimental-0cdfef19b-20231211", | ||
"react-dom": "0.0.0-experimental-0cdfef19b-20231211" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.2" | ||
}, | ||
"resolutions": { | ||
"react": "0.0.0-experimental-0cdfef19b-20231211", | ||
"react-dom": "0.0.0-experimental-0cdfef19b-20231211" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineAppConfig } from 'ice'; | ||
|
||
export default defineAppConfig(() => ({})); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Meta, Title, Links, Main, Scripts } from 'ice'; | ||
|
||
function Document() { | ||
return ( | ||
<html> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="description" content="ICE Demo" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Title /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Main /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
export default Document; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Link } from 'ice'; | ||
import Counter from '@/components/Counter'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main> | ||
<h2>Home</h2> | ||
<Counter /> | ||
<Link to="/about">About</Link> | ||
</main> | ||
); | ||
} | ||
|
||
export function pageConfig() { | ||
return { | ||
title: 'Home', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { KeepAliveOutlet } from 'ice'; | ||
|
||
export default function Layout() { | ||
return ( | ||
<> | ||
<h1>I'm Keep Alive</h1> | ||
<KeepAliveOutlet /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"module": "esnext", | ||
"target": "es6", | ||
"jsx": "react-jsx", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"lib": ["es6", "dom"], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"rootDir": "./", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": false, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"paths": { | ||
"@/*": ["./src/*"], | ||
"ice": [".ice"] | ||
} | ||
}, | ||
"include": ["src", ".ice", "ice.config.*"], | ||
"exclude": ["build", "public"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useState } from 'react'; | ||
|
||
export default function Count() { | ||
const [count, setCount] = useState(0); | ||
return ( | ||
<div> | ||
<p>count: {count}</p> | ||
<button onClick={() => setCount(count + 1)}>add</button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Link } from 'ice'; | ||
import Count from '@/components/Count'; | ||
|
||
export default function Home() { | ||
return ( | ||
<div> | ||
<h4>Home</h4> | ||
<Count /> | ||
<Link to="/">Index</Link> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import { Link } from 'ice'; | ||
import Counter from '@/components/Counter'; | ||
import { useEffect } from 'react'; | ||
import { useActive, Link } from 'ice'; | ||
import Count from '@/components/Count'; | ||
|
||
export default function Home() { | ||
const active = useActive(); | ||
|
||
useEffect(() => { | ||
if (active) { | ||
console.log('Page Index is actived'); | ||
} else { | ||
console.log('Page Index is deactived'); | ||
} | ||
}, [active]); | ||
|
||
return ( | ||
<main> | ||
<h2>Home</h2> | ||
<Counter /> | ||
<Link to="/about">About</Link> | ||
</main> | ||
<div> | ||
<h4>Index</h4> | ||
<Count /> | ||
<Link to="/home">Home</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export function pageConfig() { | ||
return { | ||
title: 'Home', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
|
||
interface ActivityProps { | ||
mode: string; | ||
children: React.ReactElement | null; | ||
} | ||
|
||
interface ActivityContext { | ||
active: boolean; | ||
} | ||
|
||
const Context = React.createContext<ActivityContext>(null); | ||
const ActivityProvider = Context.Provider; | ||
|
||
export const useActive = () => { | ||
const data = React.useContext(Context); | ||
return data?.active; | ||
}; | ||
|
||
export default function Activity({ mode, children }: ActivityProps) { | ||
const active = mode === 'visible'; | ||
return ( | ||
<ActivityProvider value={{ | ||
active, | ||
}} | ||
> | ||
{/* Additional wrapper for hidden elements */} | ||
<div style={{ display: active ? 'block' : 'none' }}> | ||
{children} | ||
</div> | ||
</ActivityProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters