question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Nuxt] Unable to render map when wrapped in <no-ssr>

See original GitHub issue

Hello ! When using the nuxt <no-ssr> components that delays the render of a component until the page is mounted (to ensure it’s only rendered when the window is ready), I do not manage to render the component. To simplify the tests, i rewrote my component like so:

<template>
	 <section class="page stores">
		<vl-map
			v-if="mounted"
			id="stores__container"
			ref="map"
			:controls="false"
			data-projection="EPSG:4326">
			<vl-view
				ref="view"
				:zoom.sync="zoom"
				:center.sync="center">
			</vl-view>

			<vl-layer-tile id="osm">
				<vl-source-osm></vl-source-osm>
			</vl-layer-tile>
		</vl-map>
	</section>
</template>

<script>
export default {
	name: 'Stores',
	data() {
		return {
			mounted: false
		}
	},
	mounted() {
		this.mounted = true
	}
}
</script>

When the component is mounted:

  • the reference exists in the context this.$refs.map but it seems that the vl-map component is not rendered
  • I can access the component map like so this.$refs.map.$map so it seems to be instantiated;
  • the this.$refs.map.$map.isRendered() method returns me false so it seems that it is not rendered yet but I can’t find a way to trigger a re-render.

Does anyone has an idea on how to trigger a re-render on the component ? Thanks in advance for your replies (and thanks to the author for the supernice work!)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
felixdenoixcommented, May 9, 2019

Hey @mgiraldo ! for starters i created a plugin:

import Vue from 'vue'
import VueLayers from 'vuelayers'
import 'vuelayers/lib/style.css' // needs css-loader

Vue.use(VueLayers)

and a module :

module.exports = function (moduleOptions) {
	this.options.css.push('vuelayers/lib/style.css')
}

It allows me to load the component and the styles as demonstrated in the doc here and then I include it in the nuxt config with the ssr: false since the window object is required:

plugins: [{
		src: '@/plugins/vueLayers',
		ssr: false
	}, { ... }],
modules: [
                ...,
		'~/shared/vueLayers',
	],

Afterwards have a look to the previous responses, you should have all the informations needed. Hope that helps !

1reaction
felixdenoixcommented, Feb 20, 2019

For anyone passing by the working shape of the component is the following

    <template>
	 <section class="stores">
		<div class="stores__wrapper">
			<transition name="fade">
				<vl-map
					v-if="mounted"
					id="stores__container" ...
                                 ...  
				</vl-map>
			</transition>
		</div>
          </section>
    </template>

and the style

.stores {
	display: flex;
}
.stores__wrapper {
	height: 100vh;
	width: 100vw;
}
#stores__container {
	position: relative;
	width: 100vw;
	height: 100vh;

	canvas, .vl-map  {
		height: 100vh;
		width: 100vw;
	}
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Non-SSR Friendly Components with Next.js
For example, let's assume that Home component is needed to be rendered on the client-side. Here's how we do it. import React from...
Read more >
Server Side Rendering - Nuxt
Server-side rendering (SSR), is the ability of an application to contribute by displaying the web-page on the server instead of rendering it in...
Read more >
Nuxt pre-rendering command fails to generate static routes
I am unable to reproduce this behaviour with a new project created by running npx create-nuxt-app <project-name> . Additionally, I was able ...
Read more >
Does Blood Pressure Medicine Make Your Nose Run [Tenex] How ...
Although it can t look down on people, someone can report a letter does blood pressure medicine make your nose run or something...
Read more >
Medicare Claims Processing Manual Chapter 4, Part B Hospital
250.3.2 - Physician Rendering Anesthesia in a Hospital Outpatient Setting ... reported on the same claim is packaged into payment for the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found