Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Fix warning appearing in tests #1960

Closed
jackcmeyer opened this issue Apr 3, 2020 · 5 comments 路 Fixed by #2016
Closed

Fix warning appearing in tests #1960

jackcmeyer opened this issue Apr 3, 2020 · 5 comments 路 Fixed by #2016
Labels
馃悰bug issue/pull request that documents/fixes a bug in progress indicates that issue/pull request is currently being worked on LOE - unkown indicates that the level of effort to complete issue is unknown (likely more research is needed)
Projects
Milestone

Comments

@jackcmeyer
Copy link
Member

馃悰 Bug Report

This warning is appearing when running tests:

    console.error ../../node_modules/react-test-renderer/cjs/react-test-renderer.development.js:120
      Warning: Cannot update a component (`ButtonBarProvider`) while rendering a different component (`TestHook`). To locate the bad setState() call inside `TestHook`, follow the stack trace as described in https://fb.me/setstate-in-render
          in TestHook
          in Suspense
          in ButtonBarProvider (at ButtonBarProvider.test.tsx:14)
          in wrapper

To Reproduce

run yarn test

Expected behavior

I would expect that warning not to appear.

Your Environment

@jackcmeyer jackcmeyer added 馃悰bug issue/pull request that documents/fixes a bug help wanted indicates that an issue is open for contributions labels Apr 3, 2020
@jackcmeyer jackcmeyer added this to the v2.0 milestone Apr 3, 2020
@jackcmeyer jackcmeyer added this to To do in Version 2.0 via automation Apr 3, 2020
@hemantpandey17
Copy link
Contributor

I can take a look on this.

@jackcmeyer
Copy link
Member Author

sounds great, @hemantpandey17!

@jackcmeyer jackcmeyer added in progress indicates that issue/pull request is currently being worked on and removed 馃悰bug issue/pull request that documents/fixes a bug labels Apr 4, 2020
@jackcmeyer
Copy link
Member Author

After looking at some more logs, the same warning message can be seen when running the application.

@hemantpandey17
Copy link
Contributor

After looking at some more logs, the same warning message can be seen when running the application.

Yes Jack, I saw the logs while running the application. All of them are pointing to a single function (setButtonToolbar()). Will look more into it, might need some guidance here.

@jackcmeyer jackcmeyer added 馃悰bug issue/pull request that documents/fixes a bug LOE - unkown indicates that the level of effort to complete issue is unknown (likely more research is needed) and removed help wanted indicates that an issue is open for contributions labels Apr 6, 2020
@hemantpandey17
Copy link
Contributor

hemantpandey17 commented Apr 6, 2020

Hello @jackcmeyer ,

Based on my codewalk,

` const setButtonToolBar = useButtonToolbarSetter()

const buttons = []
if (permissions.includes(Permissions.WritePatients)) {
buttons.push(
<Button
key="editPatientButton"
color="success"
icon="edit"
outlined
onClick={() => {
history.push(/patients/edit/${patient.id})
}}
>
{t('actions.edit')}
,
)
}

setButtonToolBar(buttons)`

The above piece of code piece the warning. The warning appears on calling setButtonToolBar(buttons). For me , it appears this is adding button based on permission to the button toolbar.

Not sure, why it is giving a warning. If you can throw more light on this, it would be really grateful.

Here is the warning info. :WordPress/gutenberg#21049

@hemantpandey17 hemantpandey17 removed their assignment Apr 10, 2020
Version 2.0 automation moved this from To do to Done Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
馃悰bug issue/pull request that documents/fixes a bug in progress indicates that issue/pull request is currently being worked on LOE - unkown indicates that the level of effort to complete issue is unknown (likely more research is needed)
Projects
Version 2.0
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants