reactstrap icon indicating copy to clipboard operation
reactstrap copied to clipboard

Usage of legacy context API

Open thetric opened this issue 6 years ago • 36 comments

  • components: TabPane, Dropdown(,Item,Menu,Toggle), Manager, PopperTargetHelper, CarousellItem (see https://github.com/reactstrap/reactstrap/search?q=contextTypes&unscoped_q=contextTypes)
  • reactstrap version 6.5.0
  • import method: es
  • react version 16.7.0
  • bootstrap version 4.2.1

What is happening?

When using <React.StrictMode> Reacts advises against using the legacy context API:

Warning: Legacy context API has been detected within a strict-mode tree: 
    in StrictMode (at App.tsx:27)
    in App (at src/index.tsx:7)

Please update the following components: Dropdown, DropdownItem, DropdownMenu, DropdownToggle, Manager

Learn more about this warning here:
https://fb.me/react-strict-mode-warnings

From https://reactjs.org/docs/context.html#legacy-api:

React previously shipped with an experimental context API. The old API will be supported in all 16.x releases, but applications using it should migrate to the new version. The legacy API will be removed in a future major React version. [...]

What should be happening?

Reactstrap should be using the new Context API.

Steps to reproduce issue

Wrap an example app using some of the components mentions at the beginning in React.StrictMode and start it in development mode.

Code

https://stackblitz.com/edit/reactstrap-saxswj?file=Example.js

thetric avatar Dec 28 '18 14:12 thetric

The Modal component uses deprecated lifecycle hooks:

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: Modal

componentWillUpdate: Please update the following components to use componentDidUpdate instead: Modal

thetric avatar Feb 06 '19 14:02 thetric

I'll submit a PR for it!

gergely-nagy avatar Feb 06 '19 22:02 gergely-nagy

Duplicate of https://github.com/reactstrap/reactstrap/issues/1159

iegik avatar Aug 12 '19 08:08 iegik

@gergely-nagy any progress?

armenzg avatar Dec 12 '19 15:12 armenzg

Same thing on Collapse: image

jonathan-richer avatar Jun 03 '20 20:06 jonathan-richer

I got this warning with Tooltip, if that helps.

sumanthratna avatar Jun 22 '20 16:06 sumanthratna

I got this warning with Carousel.

MA-Ahmad avatar Jun 26 '20 04:06 MA-Ahmad

Anyone interested in fixing this? Here Is a starting point https://github.com/reactstrap/reactstrap/pull/1866 One test is failing. I can't alocate more time.

iamandrewluca avatar Jun 26 '20 06:06 iamandrewluca

I got this warning with Tooltip

kindyALkindy avatar Jul 07 '20 14:07 kindyALkindy

Also happening in Fade component

rmlevangelio avatar Jul 13 '20 05:07 rmlevangelio

I got this warning with Collapse navbar.

ka-dev12 avatar Jul 17 '20 02:07 ka-dev12

Got this warning in in Transition (created by Collapse) in Collapse (at AppNavbar.js:24) in div (created by Container) in Container (at AppNavbar.js:21) in nav (created by Navbar) in Navbar (at AppNavbar.js:20) in div (at AppNavbar.js:19) in AppNavbar (at App.js:10) in div (at App.js:9) in App (at src/index.js:8) in StrictMode (at src/index.js:7)

hauchongtang avatar Jul 20 '20 09:07 hauchongtang

We know about this issue.

Legacy context is used only in Carousel right now, no other places.

All other warnings come from components that use react-transition-group, if you enable StrictMode, because it uses deprecated findDOMNode API

There is no more reasons to post about it.

iamandrewluca avatar Jul 20 '20 09:07 iamandrewluca

Same thing on Collapse: image

Even I get similar warning, is there a work around or fix for this?

vishaloswal avatar Jul 23 '20 13:07 vishaloswal

Workaround: Remove strictMode from index.js

SumitJadiya avatar Aug 07 '20 16:08 SumitJadiya

It is not resolved yet

xreider avatar Dec 02 '20 06:12 xreider

@xreider do you want to help fixing it?

iamandrewluca avatar Dec 02 '20 07:12 iamandrewluca

In index.js change React.StrictMode toReact.Fragment @@

manhddse03539 avatar Dec 04 '20 08:12 manhddse03539

Alert is causing this issue for me

chauger avatar Dec 10 '20 20:12 chauger

switch to <React.Fragment> in index.js

adamf1631 avatar Jan 20 '21 19:01 adamf1631

React.Fragment is not an alternative for React.StrictMode 🙂

iamandrewluca avatar Jan 21 '21 09:01 iamandrewluca

@iamandrewluca CMIIW the problem comes from react-transition-groups (as you said). Reactstrap is using that library at version 2.9.0. But last version is 4.4.1. Would it still happen in a more recent version? What's blocking reactstrap from updating?

d3ce1t avatar Jan 22 '21 21:01 d3ce1t

My guess is that the author wants to support React < 16.3 which has no the new Context API. But react-transition-groups@3 requires the new Context API

thetric avatar Jan 23 '21 18:01 thetric

We don't have time to allocate for this. And because this will be a breaking change, we thought of making multiple breaking changes at a time. But for that we have to allocate a lot of time, which we don't have.

iamandrewluca avatar Jan 23 '21 19:01 iamandrewluca

Yes, I found this warning as well, if you boys have any suggestions please step up and suggest. Thanks!

adamf1631 avatar Jan 28 '21 15:01 adamf1631

Same problem I'm facing when using Collapse from reactstrap. Is there any solution? Thanks

Screenshot 2021-02-09 at 9 16 35 PM

mazharvai007 avatar Feb 09 '21 15:02 mazharvai007

Has this issue really been on for more than two years? I keep getting an error when using the Carousel component

CleverOscar avatar Feb 16 '21 22:02 CleverOscar

İndex.js değişikliklerinde React.StrictModeiçin React.Fragment@@

thankx :)

dogukankutluay avatar Feb 22 '21 11:02 dogukankutluay

React.Fragment if you are beginner you can use it temporily :)

musasahinkundakci avatar May 08 '21 10:05 musasahinkundakci

Deleting "<React.Fragment>" in the index.js file may also be effective. I chose to use it this way to solve it; " ReactDOM.render(<App />,document.getElementById('root')); "

But since I'm newbie to React, I'm not sure how the right step is

fsogutcen avatar May 09 '21 12:05 fsogutcen