reactjs

How to add Adsense to a website built with GatsbyJS?

梦想的初衷 提交于 2021-02-17 08:47:19
问题 I'd like to know where I should add the <script></script> provided by Google Adsense. They say to add it into the <head></head> , but in Gatsby you have Helmet as <head> . I tried also to add the script inside an html.js file where it's located a <head> tag with {``} to escape the <script> tag, but it outputs at the top of the website the script content. TL;DR: What is the optimal way to add Adsense to a website built with GatsbyJS? I've tried to use the react adsense package but I do not

CORS problem with NodeJS Express and ReactJS

天大地大妈咪最大 提交于 2021-02-17 07:11:13
问题 I have some CORS problem with NodeJS Express and ReactJS. Please help me. Now, I have both frontend( http://locahost:3000 ) and backend( http://locahost:4000 ) using different PORT . The frontend is using 3000 port with ReactJS and the Backend is using 4000 port with NodeJS Express. Frontend API call source code axios.get("/tube/latestted", { headers: { "Content-Type": "application/json", }, }) .then(response => { console.log(response); }); Backend CORS setting source code app.all('/*',

CORS problem with NodeJS Express and ReactJS

ぐ巨炮叔叔 提交于 2021-02-17 07:11:13
问题 I have some CORS problem with NodeJS Express and ReactJS. Please help me. Now, I have both frontend( http://locahost:3000 ) and backend( http://locahost:4000 ) using different PORT . The frontend is using 3000 port with ReactJS and the Backend is using 4000 port with NodeJS Express. Frontend API call source code axios.get("/tube/latestted", { headers: { "Content-Type": "application/json", }, }) .then(response => { console.log(response); }); Backend CORS setting source code app.all('/*',

GatsbyJS - Blog posts not loading on direct link

╄→尐↘猪︶ㄣ 提交于 2021-02-17 07:05:47
问题 I've been playing with Gatsby for a while now and absolutely love it. I did come across a little issue that I have no clue how to fix. I'm rendering blogs posts from my markdown files. Functionality of the site works fine when you start the site by visiting the homepage / root. https://www.ronaldlangeveld.com/ However, I'm having issues with direct links to my blog posts. I can access the blog posts by clicking on links from the homepage. However, when trying to access a specific page via

React conditionally render a component in specific routes

孤人 提交于 2021-02-17 06:37:07
问题 This is my Index.js ReactDOM.render( <React.StrictMode> <Provider store={store}> <Router> <App className="app-main" /> </Router> </Provider> </React.StrictMode>, document.getElementById('root') ); And here is App.jsx <Switch> appRoutes.map(route => <Route path={route.path} component={route.component} key={route.key}/> )} </Switch> <BottomNav /> I want to render the BottomNav component in specific routes in which they are some sub routes too. I used withRouter in the Bottom nav but its match

Conditional dropdowns with react-select and react-final-form field arrays

。_饼干妹妹 提交于 2021-02-17 06:28:25
问题 I'm using react-select with react-final-form and I need to have two selects, where the selected option in the first select dynamically sets the options for the second select. For example, when option One is selected in the first select, the second select gets options One A and One B. These selects are used in an array. Here is my codesandbox with initial setup https://codesandbox.io/s/react-final-form-field-arrays-e4mm6?fontsize=14. I've found two similar examples, but I don't know how to

Emotion Js Hamburger animation

六月ゝ 毕业季﹏ 提交于 2021-02-17 06:26:06
问题 Hello I'm trying to make an animation with emotion js typescript and redux for some reason my animation is not working I don't know if the problem is in my type because my state works normally as in the image: Code : TSX : interface RootState { sideBarStatus: boolean; } interface SideBar { isOpen: boolean; } const LogoNavigation: React.FC<SideBar> = ({ isOpen }) => { const dispatch = useDispatch(); console.log(isOpen); return ( <LogoSide> <img src={Logo} alt="Logo Elo Ghost" /> <Hamburguer

Is there a function, like componentWillUnmount, that will fire before the page is refreshed

给你一囗甜甜゛ 提交于 2021-02-17 06:24:05
问题 I want a function, to send a request to a server (don't care about response) before a user refreshes the page. I've tried using the componentWillUnmount approach but the page refresh doesn't call this function. e.g. import React, { useEffect } from 'react'; const ComponentExample => () => { useEffect(() => { return () => { // componentWillUnmount in functional component. // Anything in here is fired on component unmount. // Call my server to do some work } }, []) } Does anyone have any ideas

Used the reactjs in vscode was report an error

青春壹個敷衍的年華 提交于 2021-02-17 06:23:06
问题 use "jsx" grammar in visual studio code. visual studio code report an error Please help me. Thanks!!! 回答1: The symbol "<" should appear in the same line with the tag name. For example, instead of doing that: return ( < button className="square"> {/*TODO*/} < /button> ) Do that: return( <button className="square"> {/*TODO*/} </button> ) If you want to split the tag to multiple lines, you can do it like that: return ( <button className="square" id="id" onClick={someFunc} > {/*TODO*/} </button>

Apollo React - `useMutation` in ApolloClient setup?

给你一囗甜甜゛ 提交于 2021-02-17 06:12:14
问题 I have an interesting situation. I want to initiate refresh token request USING Apollo itself (a.k.a to call a mutation) Any idea, how to achieve something like this? export default new ApolloClient({ link: ApolloLink.from([ onError(({ graphQLErrors, networkError, operation, forward }) => { // useMutation(REFRESH_ACCESS_TOKEN) }), ]), new HttpLink({...}), }) Basically I'm just trying to useMutation(REFRESH_ACCESS_TOKEN) inside onError while creating new ApolloClient instance. The problem: