Giter VIP home page Giter VIP logo

Comments (5)

hellofantastic avatar hellofantastic commented on July 3, 2024

After it became available in web 365 I logged in with safari and tried to access the add In same issue blank after load but the console of Safari provided more info

Screen Shot 2021-04-20 at 8 39 57 PM

from office-addin-taskpane-react-js.

hellofantastic avatar hellofantastic commented on July 3, 2024

So it may in fact be react-router-dom which I am using for navigation.
I have followed recommended steps to get it working which it does in development by putting this in taskpane.html

    <script type="text/javascript">
        // Office js deletes window.history.pushState and window.history.replaceState. Cache them and restore them
        window._historyCache = {
            replaceState: window.history.replaceState,
            pushState: window.history.pushState
        };
    </script>
    <!-- Office JavaScript API -->
    <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
    <script type="text/javascript">
        // Office js deletes window.history.pushState and window.history.replaceState. Restore them
        window.history.replaceState = window._historyCache.replaceState;
        window.history.pushState = window._historyCache.pushState;
    </script>

and I can see its still there in the production version of taskpane.html

Is it that in production the Office environment sees <Router></Router> and just says nope not going to even render whats inside

from office-addin-taskpane-react-js.

hellofantastic avatar hellofantastic commented on July 3, 2024

Okay
So the question is how do you get react-router-dom to work in production?

from office-addin-taskpane-react-js.

hellofantastic avatar hellofantastic commented on July 3, 2024

Heres My App.js code using react-router-dom

import * as React from "react";
import {
  BrowserRouter as Router,
  Route,
  Link
} from 'react-router-dom'
import Progress from "./Progress";
import HomeMenu from './HomeMenu';

const routes = [
  {
    path: '/taskpane.html',
    exact: true,
    menu: () => <HomeMenu />,
    main: () => <div></div>
  },
  {
    path: '/newthing',
    menu: () => <div><Link to="/taskpane.html">Back</Link></div>,
    main: () => <h2>New Thing Component</h2>
  },
  {
    path: '/nextthing',
    menu: () => <div><Link  to="/taskpane.html">Back</Link></div>,
    main: () => <h2>Next thing Component</h2>
  },
  {
    path: '/bottlenecks',
    menu: () => <div><Link to="/taskpane.html">Back</Link></div>,
    main: () => <h2>Another Component</h2>
  }
]

const App = ({ title, isOfficeInitialized }) => {

    if (!isOfficeInitialized) {
      return (
        <Progress title={title} logo="assets/logo-filled.png" message="Please sideload your addin to see app body." />
      );
    }

    return (
      <div className="ms-welcome test">
      <Router>
      {
        routes.map((route) => (
          <Route
            key={route.path}
            path={route.path}
            exact={route.exact}
          >
            <route.menu /> 
          </Route>
        ))
      }
      {
        routes.map((route) => (
          <Route
            key={route.path}
            path={route.path}
            exact={route.exact}
          >
            <route.main />
          </Route>
        ))
      }
      </Router>
      </div>
    );
  }

  export default App;

from office-addin-taskpane-react-js.

hellofantastic avatar hellofantastic commented on July 3, 2024

Holy cow got it to work ... starting looking at window .location in console of browser for production install and of course my routes had paths as /taskpane.html and once being served from mydomain.com/dist/taskpane.html of course browserRouter isn't even going to render AND show no error no equal paths... /taskpane.html !== /dist/taskpane.html jeez.

from office-addin-taskpane-react-js.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.