Any help would be greatly appreciated, I've built out a simple quote generator project in React and would like the new quote to load without rendering the entire page. Currently, im using hooks and the quotes state resides in one component is it possible to reload/refresh state from another component using a click handler?
Project link: https://codesandbox.io/s/quote-generator-czffn?file=/src/components/buttons/Buttons.js
How it's currently reloading, using a refreshPage function. Thanks!
import React from 'react';
const Buttons = ({ quotes, getNewQuote }) => {
const twitterUrl = `https://twitter.com/intent/tweet?text=${quotes.joke}`;
// console.log(twitterUrl);
function refreshPage() {
window.location.reload(false);
}
return (
<div className='button-container'>
<button
onClick={() => window.open(twitterUrl, '_blank')}
className='twitter-button'
id='twitter'
tittle='Tweet This!'
>
<i className='fab fa-twitter'></i>
</button>
<button id='new-quote' onClick={refreshPage}>
New Quote
</button>
</div>
);
};
export default Buttons;