Trouble with Tweet Intent

Hello All,

I have passed the Random Quote Project, but would really like to figure out why my tweet link gets the “ is blocked - refused to connect” error.

Code below:

const quoteBox =
	"position-absolute top-50 start-50 translate-middle p-5 bg-white w-100 text-center shadow ";
const buttons = "position-absolute bottom-0 start-50 translate-middle-x p-5";
const buttonStyle = "btn btn-primary m-2";
const authorCenter = "text-center";

class Quote extends React.Component {
	constructor(props) {
		this.state = {
			data: [],
			quote: "",
			author: ""
		this.random = this.random.bind(this);
		this.handleClick = this.handleClick.bind(this);

	componentDidMount() {
			.then((response) => response.json())
			.then((data) =>
				this.setState({ data: data.quotes }, () => {

	random() {
		const randomIndex = Math.floor(Math.random() *;

	handleClick() {
		const random = this.random();
			quote: random.quote,

	render() {
		return (
				<div id={"quote-box"}>
					<div className={quoteBox}>
						{" "}
						{/*Container for quotes*/}
						<div id={"text"}>
						<div id={"author"} className={authorCenter}>
							<cite>- {}</cite>
					<div className={buttons}>
							New Quote
							<i className="fab fa-twitter"></i>

ReactDOM.render(<Quote />, document.getElementById("app"));

Works on my phone’s browser …??

You can hover over the button in your react app and see the rendered link for each quote. Comparing that to a legitimate link probably will help you.

It can also be a browser issue. Or depending on how you are rendering your project, on the environment (codepen or self-hosted github pages etc). There is an issue opened on Github that seems relevant in that case: Quote Machine Tweet button doesn't work on CodePen due to Twitter's API · Issue #40089 · freeCodeCamp/freeCodeCamp · GitHub

From your code snippet it does not look like anything is wrong.

As said it’s a restriction.

Web Intents

Web Intents cannot be loaded inside an iframe.

For all Codepen Views, except the Debug view, your code is inside an iframe. You can remove target="_blank" from the link to have it work. But it will not open up in a new tab.

Thanks for the reply - I took a look at the Github link you replied with.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.