Giter Site home page Giter Site logo

Comments (4)

kkotwal94 avatar kkotwal94 commented on May 4, 2024

Ok so I kinda understand how it works now, handler renders whatever we import, and and I changed the way my structure works as well.

<App>
 <Navbar >
   <NavMenu>
      <li className="cd-selected">
        <Link to="dashboard">Dashboard</Link>
      </li>

      <li>
        <Link to="reports">Reports</Link>
      </li>

      <li>
        <Link to="employees">Employees</Link>
      </li>

      <li>
        <a href="/logout">Logout</a>
      </li>

      <li>
        <Link to="addReport">Create New Report</Link>
      </li>
    </NavMenu>
 <RouteHandler />

Where my router is..

<Route>
 <Route name ="signup" path="/signup" handler={Signup} />
 <Route name ="login" path="/" handler={Login} />
 <Route name ="dash" path="/dashboard" handler={App}>
    <Route name ="dashboard" path="/dashboard" handler={Dashboard}/>
    <Route name ="reports" path="/reports" handler={Report} />
    <Route name ="employees" path="/employees" handler={Employees} />
    <Route name ="addReport" path="/addReport" handler={AddReports} />
 </Route>
</Route>

I don't know if I did the "dash" one correctly, but its working, on login it redirects to /dashboard in the express server, /dashboard is filled with {App} and app does its thing.

However I would still like to understand how to do logout in react router rather than express. When I add

<Route name ="logout" path="/logout" />

and then add the Link in the NavMenu, it just takes me to /logout rather than performing the same action as it would in the express server if it was at that route. I think my misunderstanding lies in that I thought by setting a route in react-route it would behave just as the one in my express server, idk If i even said that with any type of sense.

from reactgo.

choonkending avatar choonkending commented on May 4, 2024

@kkotwal94 Hey thanks for commenting!

It feels like your question is more regarding how react-router works.

I added a Logout action to my link, and made an API call to the /logout endpoint via Ajax (behind the scenes).

Does that help? Haha :)

from reactgo.

kkotwal94 avatar kkotwal94 commented on May 4, 2024

Yea it does, sorry for missing the obvious I totally skipped over the UserAPI. I was wondering how we were binding the data to the front end. I finally figured out how react-router works*, now im trying to figure out how flux works and writing react in es6.

from reactgo.

choonkending avatar choonkending commented on May 4, 2024

No worries. It might be a bit confusing at first, but now that I use the flux design pattern and es6, I can't go back!

from reactgo.

Related Issues (20)

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.