From 299e6aeb3b1ddd6d89825f3de5496aee3f2a11c0 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 31 Oct 2018 16:31:48 -0400 Subject: [PATCH] Fix issue where Instantclick navigation fails (#1047) --- app/javascript/packs/githubRepos.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/javascript/packs/githubRepos.jsx b/app/javascript/packs/githubRepos.jsx index 511a95e13..d00fb0319 100644 --- a/app/javascript/packs/githubRepos.jsx +++ b/app/javascript/packs/githubRepos.jsx @@ -1,8 +1,15 @@ import { h, render } from 'preact'; import { GithubRepos } from '../githubRepos/githubRepos'; -document.addEventListener('DOMContentLoaded', () => { +function loadElement() { const root = document.getElementById('github-repos-container'); + if (root){ + render(, root, root.firstElementChild); + } +} - render(, root, root.firstElementChild); +window.InstantClick.on('change', () => { + loadElement(); }); + +loadElement();