Skip to content

Commit

Permalink
docs: Update some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
frandiox committed Oct 10, 2021
1 parent b051c5e commit 3310792
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/react/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useState } from 'react'
import { Link, Route, Switch } from 'react-router-dom'
import logo from './logo.svg'
import { ClientOnly } from 'vite-ssr'

export default function App({ isClient, url, router, request }) {
const baseUrl = isClient ? '' : url.origin
const [count, setCount] = useState(0)
Expand Down
6 changes: 0 additions & 6 deletions examples/vue/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ export default viteSSR(

app.component(ClientOnly.name, ClientOnly)

// The 'initialState' is hydrated in the browser and can be used to
// pass it to Vuex, for example, if you prefer to rely on stores rather than page props.
// In the server, 'initialState' is an empty object that can be mutated. It can be
// passed to Vuex, or provide it to child components (see Homepage for an example).
app.provide('initialState', initialState)

// Before each route navigation we request the data needed for showing the page.
router.beforeEach(async (to, from, next) => {
if (!!to.meta.state) {
Expand Down
4 changes: 2 additions & 2 deletions examples/vue/src/pages/Homepage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script>
import { defineComponent, inject, ref } from 'vue'
import { useHead } from '@vueuse/head'
import { useContext } from 'vite-ssr/vue'
export default defineComponent({
name: 'Homepage',
Expand All @@ -28,8 +29,7 @@ export default defineComponent({
},
},
async setup() {
// This is provided in main.js
const initialState = inject('initialState')
const { initialState } = useContext()
// Hydrate from initialState, if there's anything
const homeLocalState = ref(initialState.homeLocalState || null)
Expand Down

0 comments on commit 3310792

Please sign in to comment.