Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react with routing parameter and active NavLink

//this is from index.js
const routing = (
  <Router>
    <div >
    <ul>
      <li><NavLink exact activeNameClass="active " to="/">Home</NavLink></li>
      <li><NavLink exact activeNameClass="active  "  to="/users/123">User</NavLink></li>
      <li><NavLink exact activeNameClass="active  "  to="/employee/Ryaymund">Employee</NavLink></li>
      <li><NavLink exact activeNameClass="active "  to="/contact">Contact</NavLink></li>
      </ul>
      <Switch>
      <Route exact path="/" component={App} />
      <Route  path="/users/:id" component={Users} />
      <Route  path="/employee/:name" component={Employee} />
      <Route  path="/contact" component={Contact} />
      <Route component={Notfounds}/>
      </Switch>
    </div>
  </Router>

//here is the sample from employee.js routing
import React from 'react';

class Employee extends React.Component {
    render() {
        const {params} = this.props.match
        return(
            <>
            <h1>Employee</h1>
            <p>{params.name}</p>
            </>
        )
    }
}
export default Employee
Comment

PREVIOUS NEXT
Code Example
Javascript :: Creatable Multiselect 
Javascript :: react.js form 
Javascript :: javascript one linde condition 
Javascript :: javascript Detect Cycle in a Directed Graph 
Javascript :: generate qr codes js 
Javascript :: ajaxpost 
Javascript :: Backbone Initialize vs Render 
Javascript :: get file name with extension netsuite suitescript 
Javascript :: bun javascript runtime 
Javascript :: get data from json key with special character 
Javascript :: javascript load on error 
Javascript :: make navigation open when items are active 
Javascript :: payflex api examples php 
Javascript :: load image file input jquery 
Javascript :: react createelement data attribute 
Javascript :: make react navigation to always re render 
Javascript :: index wise print elemnet in javascript 
Javascript :: upload file to api angular 
Javascript :: reverse an array in javascript 
Javascript :: d3 js date scatter plot 
Javascript :: how to get a set of values in mogodb 
Javascript :: remove a key/value mongo 
Javascript :: button onclick link to another page react 
Javascript :: if this then this, else that 
Javascript :: dynamic call function 
Javascript :: Pointing Subdomain To A Next.js Page On Vercel 
Javascript :: Passing JSON to Javascript in Laravel – but JS is converting the JSON to HTML Entities 
Javascript :: How to add ui-scroll with remote data in angularjs 
Javascript :: Calling $http.post in batches and chaining promises 
Javascript :: check if Popups and Redirects are allowed 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =