From 3ef7a9bf0643fcd01e06d02fb30a2d09eedf5b8f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 26 May 2022 13:27:46 -0700 Subject: [PATCH] docs: add hackernews demo --- package.json | 2 +- .../docs/pages/docs/concepts/reactivity.mdx | 5 + .../docs/pages/examples/examples-menu.json | 12 + .../examples/partial/hackernews-index/app.tsx | 155 +++++++++++ .../partial/hackernews-index/entry.server.tsx | 6 + .../partial/hackernews-index/hacker-news.css | 262 ++++++++++++++++++ .../partial/hackernews-index/root.tsx | 14 + 7 files changed, 455 insertions(+), 1 deletion(-) create mode 100644 packages/docs/pages/examples/partial/hackernews-index/app.tsx create mode 100644 packages/docs/pages/examples/partial/hackernews-index/entry.server.tsx create mode 100644 packages/docs/pages/examples/partial/hackernews-index/hacker-news.css create mode 100644 packages/docs/pages/examples/partial/hackernews-index/root.tsx diff --git a/package.json b/package.json index ddfe6525af2..d380aae87fd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "qwik-monorepo", - "version": "0.0.21", + "version": "0.0.21-0", "scripts": { "build": "yarn node scripts --tsc --build --api --platform-binding-wasm-copy", "build.full": "yarn node scripts --tsc --build --api --eslint --platform-binding --wasm", diff --git a/packages/docs/pages/docs/concepts/reactivity.mdx b/packages/docs/pages/docs/concepts/reactivity.mdx index e814a020ec1..f7b26e10d00 100644 --- a/packages/docs/pages/docs/concepts/reactivity.mdx +++ b/packages/docs/pages/docs/concepts/reactivity.mdx @@ -1,3 +1,8 @@ +--- +title: Overview +fetch: https://hackmd.io/@mhevery/SyYrShReq +--- + # Reactivity Reactivity is a key component of Qwik. Reactivity allows Qwik to track which components are subscribed to which state. This information enables Qwik to invalidate only the relevant component on state change, which minimizes the number of components that need to be rerendered. Without reactivity, a state change would require rerendering from the root component, which would force the whole component tree to be eagerly downloaded. diff --git a/packages/docs/pages/examples/examples-menu.json b/packages/docs/pages/examples/examples-menu.json index 6c3b00cbc55..a4f17431614 100644 --- a/packages/docs/pages/examples/examples-menu.json +++ b/packages/docs/pages/examples/examples-menu.json @@ -40,5 +40,17 @@ "icon": "⏰" } ] + }, + { + "id": "partial", + "title": "Partial", + "apps": [ + { + "id": "hackernews-index", + "title": "HackerNews", + "description": "HackerNews landing page", + "icon": "📰" + } + ] } ] diff --git a/packages/docs/pages/examples/partial/hackernews-index/app.tsx b/packages/docs/pages/examples/partial/hackernews-index/app.tsx new file mode 100644 index 00000000000..8043fdd90ea --- /dev/null +++ b/packages/docs/pages/examples/partial/hackernews-index/app.tsx @@ -0,0 +1,155 @@ +import { component$, useServerMount$, useStore, useStyles$ } from '@builder.io/qwik'; +import HackerNewsCSS from './hacker-news.css'; + +export const HackerNews = component$(() => { + useStyles$(HackerNewsCSS); + const store = useStore({ data: null }); + + useServerMount$(async () => { + const response = await fetch('https://node-hnapi.herokuapp.com/news?page=0'); + store.data = await response.json(); + }); + + return ( + <> +