react

fontawesome in react

1. Install FontAwesome First npm i —save @fortawesome/fontawesome–svg–core npm install —save @fortawesome/free–solid–svg–icons npm install —save @fortawesome/react–fontawesome npm install —save @fortawesome/free–brands–svg–icons npm install —save @fortawesome/free–regular–svg–icons 2. Import to your component import { FontAwesomeIcon } from ‘@fortawesome/react-fontawesome’ import { faCoffee } from ‘@fortawesome/free-solid-svg-icons’ 3. Now you can use inside your html <FontAwesomeIcon icon={faCoffee} size=“5x”/> All other style …

fontawesome in react Read More »

react button click with argument

 <div className=“d-flex justify-content-between”> <div> <button type=“button” className=“btn btn-primary” onClick={() => handleBtnClick(‘-1’)}> &larr; Previous</button> </div> <div> <button type=“button” className=“btn btn-primary” onClick={() => handleBtnClick(‘+1’)}>Next &rarr;</button> </div> </div>

using same component for different route path in react-router v6

Using different key for each route should force components to rebuild: import React, { Component } from ‘react’;import Navbar from ‘./Components/Navbar’;import News from ‘./Components/News’;import Test from ‘./Components/Test’;import NoMatch from ‘./Components/NoMatch’;import { BrowserRouter , Route, Routes } from ‘react-router-dom’export default class App extends Component { render() { return <div> <BrowserRouter> < Navbar /> <Routes> <Route path=”/” element={<News pageSize={8} …

using same component for different route path in react-router v6 Read More »

Use React Router Dom V6

   install latest versionnpm install react-router-dom For v6 use belowimport React, { Component } from ‘react’;import Navbar from ‘./Components/Navbar’;import News from ‘./Components/News’;import { BrowserRouter as Router, Route, Routes } from ‘react-router-dom’export default class App extends Component { render() { return <div> <Router> < Navbar /> <Routes> <Route exact path=”/” element={<News pageSize={8} category=”general”/>}/> <Route exact path=”/business” …

Use React Router Dom V6 Read More »

fixed ‘Switch’ is not exported from ‘react-router-dom’

  I also faced the same problem, and I searched the Internet so much, but I didn’t get any answer according to my question. So I uninstalled version 6 of react-router-dom: npm uninstall react-router-dom And installed version 5.2.0 of react-router-dom: npm install [email protected] use below import { BrowserRouter as Router, Switch, Route, Link} from “react-router-dom”;export …

fixed ‘Switch’ is not exported from ‘react-router-dom’ Read More »