Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router Not Working #67

Open
Spectrevuln-sketch opened this issue Jan 12, 2022 · 2 comments
Open

Router Not Working #67

Spectrevuln-sketch opened this issue Jan 12, 2022 · 2 comments

Comments

@Spectrevuln-sketch
Copy link

Spectrevuln-sketch commented Jan 12, 2022

i have some project and i wanna build wp theme with create-react wptheme but route is not working
i already follow some tutorial in http://michaelsoriano.com/wordpress-theme-react-part-2-routes-context/ but router still not working
this my code below

import React from 'react'
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import Archive from './templates/Archive';
import Single from './templates/Single';


const Routes = () => {
    return (

        <Router>
            <Switch>
                <Route exact path="/" component={Archive} />
                <Route path="/page" component={Single} />
            </Switch>
        </Router>
    )
}

export default Routes

in the single page

import React from 'react'

const Single = (props) => {
    return (
        <div className="Post">
            PAge Single
        </div>
    )
}

export default Single

i use react-router-dom version 5.3.0

@WeamAdel
Copy link

WeamAdel commented May 25, 2022

It did not work for me either, maybe you should consider using the new router API, this worked for me.

@PeterHaughie
Copy link

Can you give an example? We're trying to bring this project up to React Router Dom v6 and the Context.js is proving hard to pin down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants