Skip to content

Commit

Permalink
Merge pull request #42 from vtex-apps/fix/loop
Browse files Browse the repository at this point in the history
Fix infinite loop due useCallback wrong dependency
  • Loading branch information
jgfidelis authored Mar 20, 2019
2 parents dbe9a08 + b190f47 commit 5df2bf9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.8.1] - 2019-03-20

### Fixed

- Infinite loop on useCallback.

## [2.8.0] - 2019-03-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vendor": "vtex",
"name": "telemarketing",
"version": "2.8.0",
"version": "2.8.1",
"title": "VTEX Telemarketing",
"defaultLocale": "pt-BR",
"description": "The VTEX telemarketing app",
Expand Down
19 changes: 8 additions & 11 deletions react/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { compose, path } from 'ramda'
import React, { useState, useCallback } from 'react'
import React, { useState } from 'react'
import { graphql } from 'react-apollo'
import { injectIntl } from 'react-intl'
import { withSession } from 'vtex.render-runtime'
Expand Down Expand Up @@ -30,14 +30,11 @@ const TelemarketingContainer = (props: Props) => {
const { intl, session } = props
const processedSession = processSession(session)

const handleInputChange = useCallback(
(event: any) => {
setEmailInput(event.target.value)
},
[event]
)
const handleInputChange = (event: any) => {
setEmailInput(event.target.value)
}

const handleDepersonify = useCallback(() => {
const handleDepersonify = () => {
const { depersonify, session } = props
setloadingImpersonate(true)
depersonify()
Expand All @@ -48,9 +45,9 @@ const TelemarketingContainer = (props: Props) => {
setEmailInput('')
})
.catch(() => setloadingImpersonate(false))
}, [])
}

const handleSetSession = useCallback((email: string) => {
const handleSetSession = (email: string) => {
const { impersonate, session } = props
setloadingImpersonate(true)
const variables = { email }
Expand All @@ -64,7 +61,7 @@ const TelemarketingContainer = (props: Props) => {
setloadingImpersonate(false)
})
.catch(() => setloadingImpersonate(false))
}, [])
}

if (processedSession) {
const { client, canImpersonate, attendantEmail } = processedSession
Expand Down

0 comments on commit 5df2bf9

Please sign in to comment.