I tried nesting a <button>
tag into a <Link>
tag with the link routing to another page, but when I click the button, nothing happens. This is for a pricing card, and the code is in pricecard.js
App.js:
import logo from './logo.svg';
import './App.css';
import donenoti from './donenoti.js';
import errornoti from './errornoti.js';
import infonoti from './infonoti.js';
import pricingCard from './pricecard.js'
import personCard from './personcard.js'
function App() {
return (
<div className="App">
<header className="App-header">
<p className="titleText">mushyUI</p>
<img src={logo} className="App-logo" alt="logo" />
<h1 className="header">
Open-Source UI Elements for everyone!
</h1>
<p>Github -- <a href="https://github.com/MushyToast/ui">Github</a></p>
{donenoti("title", "description")}
{errornoti("title", "description")}
{infonoti("title", "description")}
{pricingCard("professional edition", "$19.99", "It is very much professional", "month", "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://www.youtube.com/watch?v=dQw4w9WgXcQ")}
{personCard("Quandale Dingle", "I am a person", "https://mushytoast.tech/assets/imgs/goofycapybara.png")}
</header>
</div>
);
}
export default App;
pricecard.js:
import { Link } from "react-router-dom";
function pricingCard(title, price, description, timeunit, buylink, learnmorelink) {
return (
<div className="pricingcard">
<h2 className="priceTitle">
{title}
</h2>
<h1 className="price">
{price}
<p className="priceTimeUnit">
/{timeunit}
</p>
</h1>
<p className="priceDescription">
{description}
</p>
<span className="priceCardButtons">
<a href={buylink}> {/*change to your own link */}
<button className="priceButton">
Buy Now
</button>
</a>
<Link to='./otherpage'>
<button className="learnMoreButton">
Learn More
</button>
</Link>
</span>
</div>
)
}
export default pricingCard;
otherpage.js:
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
export default function OtherPage() {
return (
<div>
<h1>Other Page</h1>
</div>
);
}
root = document.getElementById('root');
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
root
);
index.js:
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import { BrowserRouter } from 'react-router-dom'
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<BrowserRouter>
<App />
</BrowserRouter>
);
reportWebVitals();
I tried adding a rendering tag in the otherpage.js, but that made no difference, and I tried adding a .js to the otherPage in the Link to=''