Categories
Mastering Development

onClick doesn’t work on first click after rerender

const NavigationButtons = ({onBtnClicked, btnClass, label, route, btnAct}) => { return( <p className={`btn ${btnClass} ${btnAct}`} onClick={()=>onBtnClicked(route)} >{label}</p> ) } This is my button component, I’m giving it to another component as btns1 props {!isSigned?btns1:windowPixel?btns1:null} Basically, when isSigned is false, btns1 is rendered. There’s really no problem here. When isSigned is true, it checks if windowPixel […]

Categories
Mastering Development

Cannot read property ‘image’ of undefined

I am trying to build an application using react but I got an error saying "cannot read property ‘image’ of undefined" Please help me if you found any issue because I am new in this framework. The error showing up function RenderCard({ item }) { 5 | return ( 6 | <Card> > 7 | […]

Categories
Mastering Development

Why is my redux app not caching an async api call in redux-thunk?

Am new to redux. I am working now on an app that shows a list of soccer leagues in each country. Firstly, I am fetching a countries list. Afterwards, I am using the country name to loop through all countries to get the soccer leagues. Not every country has a soccer league, so I get […]

Categories
Mastering Development

How can I create a dynamic menu in ReactJS with a JSON file

I have to make a JSON file for a menu. I searched a lot but found no solution to implement it. Can you help me with that? I just want to make a menu, I think I can do it in index.js to see. here is the JSON file { "menus": [ { "key": "main", […]

Categories
Mastering Development

Why can’t I navigate to a newly added page in React?

I have react app with several pages as below. App.js import React, {useEffect} from ‘react’; import {useQuery} from ‘@apollo/react-hooks’; import {BrowserRouter as Router, Route, Switch} from ‘react-router-dom’; import {GlobalStyle} from ‘./GlobalStyles’; import {GET_AUTH_USER} from ‘graphql/user’; import {GET_NEW_CONVERSATIONS_SUBSCRIPTION} from ‘graphql/messages’; import {NOTIFICATION_CREATED_OR_DELETED} from ‘graphql/notification’; import Message from ‘components/Message’; import {Loading} from ‘components/Loading’; import AuthLayout from ‘pages/Auth/AuthLayout’; […]

Categories
CMS Drupal Mastering Development

Altering existing route for translation overview page ie: entity.node.content_translation_overview

I have followed this documentation page : https://www.drupal.org/docs/drupal-apis/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones in attempt to alter access of translation overview page ie: www.example.com/node/1/translations <?php namespace Drupal\link_enhancements\Routing; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * Listens to the dynamic route events. */ class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ public function alterRoutes(RouteCollection $collection) { $route_name = "entity.node.content_translation_overview"; var_dump($collection->get($route_name)); […]

Categories
CMS Drupal Mastering Development

Altering existing route for translation overview page ie: entity.node.content_translation_overview

I have followed this documentation page : https://www.drupal.org/docs/drupal-apis/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones in attempt to alter access of translation overview page ie: www.example.com/node/1/translations <?php namespace Drupal\link_enhancements\Routing; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * Listens to the dynamic route events. */ class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ public function alterRoutes(RouteCollection $collection) { $route_name = "entity.node.content_translation_overview"; var_dump($collection->get($route_name)); […]

Categories
Mastering Development

React-router-dom Link does not update history in jest

Example code: import React, { FC } from ‘react’; import { mount, ReactWrapper } from ‘enzyme’; import { createMemoryHistory } from ‘history’; import { MemoryRouter, Router, Route, Switch, Link } from ‘react-router-dom’; type TRoutes = { [key: string]: { title?: string; path: string; component: FC; }; }; const routes: TRoutes = { start: { title: […]

Categories
Mastering Development

React Router App gets 404 on reload of subpage – serverless, no webpack

I know this sounds exactly like a couple of older posts, but I’ve been through them, and they didn’t help. I have a very simple React App: http://bentleytech.com. It navigates fine, until you try to reload a page, or if you try to access a page directly, such as: http://bentleytech.com/Contact. Then, you get a 404 […]

Categories
Cryptocurrency Ethereum Mastering Development

Why is my @uniswap/sdk DAI/USDT price impact at 100 and returning incorrect prices?

Following the documentation here: https://uniswap.org/docs/v2/javascript-SDK/pricing/ I have been able to replicate the results using WETH, and I have decided to have a go at getting a similar result with DAI and USDT. const { ChainId, Fetcher, Route, Trade, TokenAmount, TradeType, WETH } = require(‘@uniswap/sdk’); const init = async () => { const dai = await […]