Categories
Cryptocurrency Ethereum Mastering Development

How to disconnect MetaMask wallet using Web3modal

I am using metamask with kovan to connect to the wallet import React, { useState, useEffect} from ‘react’; import Web3 from “web3”; import Web3Modal from “web3modal”; import Navbar from ‘./components/navbar’; function App() { const providerOptions = {}; const web3Modal = new Web3Modal({ network: “mainnet”, // optional cacheProvider: true, // optional providerOptions // required }); const […]

Categories
Mastering Development

Set title onSubmit based on current SELECT OPTION VALUE – react

I found this tutorial on how to create a react quizz app on youtube link to tutorial I am trying to set the title based on the current Select Option Value when submitting the form. Currently I managed to change the title only when a different option is selected. import React, { useState, useEffect, useRef […]

Categories
Mastering Development

state is not updating in react native

Actually it is not updating everywhere i suppose it to update. import React, { useState, useRef } from “react”; import { View, Text, StyleSheet, StatusBar, ScrollView, TouchableOpacity, Dimensions, ActivityIndicator, } from “react-native”; import { TextField } from “react-native-material-textfield”; import Colors from “../constants/Colors”; const welcomescreen = (props) => { let [length, setLength] = useState(); let [breadth, […]

Categories
Cryptocurrency Ethereum Mastering Development

Drizzle cacheSend outputs “cacheSend is not a function” error, but the tx works when using send

I’m using Drizzle and react-hooks in my new open source project, but cacheSend outputs always “cacheSend is not a function” This line of code with send works as expected const stackId = contract.methods.createMerchant(value.name, value.category, value.weburl).send({from: drizzleState.accounts[0]}) Instead using cacheSend returns an error “cacheSend is not a function” const stackId = contract.methods[“createMerchant”].cacheSend(value.name, value.category, value.weburl, { from: […]

Categories
Mastering Development

error in returning jsx tags as a return statement : Object doesn’t support property or method

Error: Object doesn’t support property or method ‘getTractorNumber’” What i’m trying to do is to return <Link to ={`/assign-tractor/${user_id}`}> Assign Tractor </Link> to be rendered if the tractor-id is null, Otherwise return <Link to ={`/tractor-details/${tractorId}`}>{this.tractorNumber}</Link> how can I fix my code to make it do what I want it to do? Is there a better […]

Categories
Mastering Development

Trying to use React Hook and Axios to display data from my API but nothing is rendering

Designer creating my first full-stack app to better understand more complex development concepts. I’m currently unable to get data displayed in the browser from my React app. However, unlike previous roadblocks, I’m not getting an actual error to search, so I’m not exactly sure where I’ve got a problem. The client and server seem to […]

Categories
Mastering Development

React Rest Call Infinite Loop Using Hooks

I am noticing that my component is stuck in an infinite loop. It keeps making the same rest call. It is my understanding that useEffect hooks work similar to ComponentRender and ComponentUpdate lifecycle functions. Also, I think what is happening is this but not able to fix it: On render – > API called -> […]

Categories
Mastering Development

Pass a argument to a function callback

I’m trying to use debounce in lodash to delay the onChange, see the code below. import React, { useState, useEffect, useCallback } from “react”; import { TopBar } from “@shopify/polaris”; import { debounce } from “lodash”; function SearchBar() { const [searchValue, setSearchValue] = useState(“”); const handleSearchFieldChange = ((value:string) => { setSearchValue(value); }); const debounceLoadData = […]

Categories
Mastering Development

How to pass array as result from one functional component to another in React

I want to pass data stored in const mappedData from FetchDataComponent.js to ReactSelectComponent.js. Is there any way of doing this with functional components? With code under i get Error: Objects are not valid as a React child FetchDataComponent.js import React,{useState, useEffect} from “react”; import axios from “axios”; import _ from “lodash”; const FetchDataComponent = () […]

Categories
Mastering Development

Its correct to not include a dependency on purpose on useEffect to avoid re-renderes when using react-route?

In my case here, I want to avoid the component <Checkout/> from re-rendering once I replace the url props.history.replace(props.match.path + ‘/contact-data’ to load the component <ContactData/>. As it can be seen on useEffect when <Checkout/> loads it gets a query tail on the url, something like this: http://localhost:3000/checkout?cheese=0&salad=0&special=0&veggie=1. Then I redirect to the url, having […]