HTML in React
-
Just started studying React. To enrich the skills, to redesign HTML to React. The question is: how can the button be rebuilt by reference to href on another site? Should react-router-dom be installed? I found a way to make the button component, but I couldn't find a new site. I think we'll need five different sites in five buttons. This is my code that HTML works, but it doesn't work React. Thank you all for your help.
React.
<Button href="https://github.com/Peterblr?tab=repositories"> wiew on github </Button>
HTML (to be redesigned to React)
<a href="https://github.com/Peterblr?tab=repositories" className="u-btn u-btn-round u-button-style u-radius-24 u-btn-1"> wiew on github </a>
component Button
import React from 'react'; import classNames from "classnames";
const Button = ({ onClick, className, outline, children }) => {
return (
<button
onClick={onClick}
className={classNames("u-btn u-btn-round u-button-style u-radius-24 u-btn-1", className, {
"button--outline": outline,
})}
>
{children}
</button>
);
};export default Button;
Here's what's in the package.json.
{
"name": "html-to-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"classnames": "^2.3.1",
"node-sass": "^5.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
},
-
I didn't think it was funny. Just added a reference to a href="
<Button> <a href="https://github.com/Peterblr/html-to-react" target={"_blank"}> View At Github </a>