Categories
Mastering Development

How to test amplify auth signup in react using Jest + Enzyme?

I need to test the register method along with the amplify auth signup which is written in my action file. import history from "../utils/history.helper"; import { alertInfo } from "../utils/common.helper"; import { Auth } from "aws-amplify"; export const AuthAction = { register, }; function register(signUpData) { return async (dispatch) => { const { username, password, […]

Categories
Mastering Development

react-hook-form and material-ui FormControl

So I am trying to register some radio buttons for my form, however it will not register. <FormControl component="fieldset" inputRef={register({ required: true })}> <FormLabel component="legend">Promoting</FormLabel> <RadioGroup aria-label="promoting" name="promoting" value={promoting} onChange={handleChange} inputRef={register({ required: true })}> <FormControlLabel value="business" control={<Radio />} label="Business" /> <FormControlLabel value="nonprofit" control={<Radio />} label="Non-Profit" /> <FormControlLabel value="event" control={<Radio />} label="Event" /> </RadioGroup> </FormControl> I […]

Categories
Mastering Development

How to get the text next to my checkbox inline, and next to checkbox?

I am working on a web page in which I need the text associated with each text to be next to the checkbox. Currently, this is what it looks like: Here are my JavaScript & global style code: JS: import React from ‘react’ import { Link } from ‘react-router-dom’; import { Form } from ‘../../global […]

Categories
Mastering Development

Not able to set state in React Hooks using data received from Axios

I am creating a login form using React Hooks and querying the backend using Axios. On successful login I am redirecting to the home page which is working. The problem is on unsuccessful attempt, I want to set the loginFailed to true and do the conditional rendering on the form based on this. But unfortunately […]

Categories
Mastering Development

How to redirect with axios, React Router V4 and useForm (method post) ?– ReactJS

In first, sorry for my bad english … I will try my best ! So i’m stuck . I can’t redirect my user after my request . There is my request (in component): const onSubmit = (data) =>{ const datafull = { "title": data.title, "excerpt": "nonex5", "content": data.content, "location": data.location, "company_id": "75", "category_id": data.category_id, "date_start_at": […]

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

How do I use react custom hooks to make code reusable

I have two components similar like below: const Login = props => { let loading; const dispatch = useDispatch(); const [notification, setNotification] = React.useState(”); const [hasNotification, setHasNotification] = React.useState(”); const [isLoading, setIsLoading] = React.useState(false); const {status, message} = useSelector(state => state.LoginReducer); const { register, handleSubmit, formState, errors } = useForm({ mode: “onChange” }); const onSubmit […]

Categories
Mastering Development

How to send data in a JSON format to an HTTP End Point from a custom web page?

I have created a simple custom web page using HTML and JavaScript, that allows a user to select multiple languages of their choice to translate text. For example, lets say the user chooses English(en-US) and French(fr-FR) and clicks on “Submit”. I want to take the user’s request, and send that data to an Azure Logic […]

Categories
Development

How to reset a certains fields after submit in Formik

I am using Formik and I need to make this logic. I am have a big form, and after submission I need to reset certain fields in this form There is 2 buttton: Save and Save & New save will save the data and redirect. Save & New will save the data and reset the […]

Categories
Development

How to dispatch from react-hook-form + Redux

I’m using react-hook-form (https://react-hook-form.com/). I would like to dispatch action from inside of react-hook-form. In following case, I am supposed to dispatch using props.dispatch, when onSubmit is fired. However I could not figure out how to dispatch. import React from ‘react’ import useForm from ‘react-hook-form’ export default function App() { const { register, handleSubmit, watch, […]