Hi,
I worked my way through React JS Course for Beginners - 2021 Tutorial - YouTube and decided to redo my random quote machine using React JS. My old one had stopped working probably due to the API not being available anymore.
It’s taken a while and it’s a bit hacked together but I’m pretty much done. I’m having two problems as follows.
- The Twitter icon disappears when I change the href for the tweet button.
If I set the href to “https://twitter.com/intent/tweet” then it works just fine. If I set the href to “https://twitter.com/intent/tweet?text=testing” then the tweet icon disappears altogether. I’m getting no errors that seem to relate to this. I’ve tried messing with the CSS (I’m using styled components). I can’t figure out why the icon disappears when I try to use anything other than the base URL of “https://twitter.com/intent/tweet”.
- The test suite https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js is not loading for me. It doesn’t show up on my local machine with npm start, nor in the build that I’ve deployed to Netlify. I’ve disabled addons and also tried it in Microsoft Edge. I have the script tag to include the test bundle after the closing body tag and before the closing html tag in my index.html.
Is there something else I need to do to get this to work with React and Netlify? I’ve literally just included the CDN on the index.html page and nothing else.
Netlify link: https://pedantic-dijkstra-add5bf.netlify.app/
Github: GitHub - Hallelujah78/random-quote-machine
It is probably something to do with Font Awesome but I have no idea what.
Code for the tweet component:
import React from "react";
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import { faTwitterSquare } from '@fortawesome/free-brands-svg-icons';
import {Wrapper} from './TweetQuote.styles';
const TweetQuote = () =>(
<Wrapper>
<a href="https://twitter.com/intent/tweet" id="tweet-quote" className='twitter-share-buttons'>
<FontAwesomeIcon icon={faTwitterSquare} id="twitter-quote"/></a>
</Wrapper>
);
export default TweetQuote;
The CSS:
import styled from 'styled-components';
export const Wrapper = styled.div`
display: block;
clear: both;
/*This is the <a> tag*/
.twitter-share-button{
clear: both;
float: left;
font-size: 50px;
margin-left: 0.5rem;
margin-bottom: 0.5rem;
transition: 0.4s;
path{fill: #ffc133;}
}
/*this is the button*/
#twitter-quote{
clear: both;
float: left;
font-size: 50px;
margin-left: 0.5rem;
margin-bottom: 0.5rem;
transition: 0.4s;
path{fill: #ffc133;}
}
:hover{
opacity: 0.8;
}
`;
Any hints or solutions appreciated!