Switch to desktop version  
Talk2M and Single-page application - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: Custom Web Pages/viewON/Talk2M Visualization (https://techforum.ewon.biz/forum-55.html)
+--- Thread: Talk2M and Single-page application (/thread-1035.html)



Talk2M and Single-page application - ktmachinex - 07-10-2019

Hi,

I'm currently trying to create a web page using the react framework and TypeScript. I was wondering if the Talk2M server supports SPA (Single-page application).

I'm trying to use a router which refresh a portion of my web page according to the link clicked.

It works perfectly fine when I access locally to my web page which is located on the ewon flexy 205 (ftp://[ewon ip address]/usr/dashboard/index.html).

The problem is that as soon as I use talk2m to connect to my ewon, the about and users links don't work anymore. See attachments to compare.

I've try using a BrowerRouter and an HashRouter but to no avail.

I've also tried to compare with what viewOn is doing, but there is no such thing an a link component in viewOn.

Here's the code I'm working with (taken from https://reacttraining.com/react-router/web/guides/quick-start):

Code:
import React from "react";
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom";

function Home() {
  return <h2>Home</h2>;
}

function About() {
  return <h2>About</h2>;
}

function Users() {
  return <h2>Users</h2>;
}

export default function App() {
  return (
    <Router>
      <div>
        <nav>
          <ul>
            <li>
              <Link to="/">Home</Link>
            </li>
            <li>
              <Link to="/about">About</Link>
            </li>
            <li>
              <Link to="/users">Users</Link>
            </li>
          </ul>
        </nav>

        {/* A <Switch> looks through its children <Route>s and
            renders the first one that matches the current URL. */}
        <Switch>
          <Route path="/about">
            <About />
          </Route>
          <Route path="/users">
            <Users />
          </Route>
          <Route path="/">
            <Home />
          </Route>
        </Switch>
      </div>
    </Router>
  );
}

Any help would be greatly appreciated.

Thanks,
ktmachinex