Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of legacy context API #1340

Open
thetric opened this issue Dec 28, 2018 · 36 comments
Open

Usage of legacy context API #1340

thetric opened this issue Dec 28, 2018 · 36 comments

Comments

@thetric
Copy link

thetric commented Dec 28, 2018

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
Copy link
Author

thetric commented Feb 6, 2019

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

@gergely-nagy
Copy link
Collaborator

I'll submit a PR for it!

@iegik
Copy link

iegik commented Aug 12, 2019

Duplicate of #1159

@armenzg
Copy link

armenzg commented Dec 12, 2019

@gergely-nagy any progress?

@jonathan-richer
Copy link

Same thing on Collapse:
image

@sumanthratna
Copy link

sumanthratna commented Jun 22, 2020

I got this warning with Tooltip, if that helps.

@MA-Ahmad
Copy link

I got this warning with Carousel.

@iamandrewluca
Copy link
Contributor

Anyone interested in fixing this?
Here Is a starting point #1866
One test is failing. I can't alocate more time.

@kindyALkindy
Copy link

I got this warning with Tooltip

@rmlevangelio
Copy link

Also happening in Fade component

@ka-dev12
Copy link

I got this warning with Collapse navbar.

@hauchongtang
Copy link

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)

@iamandrewluca
Copy link
Contributor

iamandrewluca commented Jul 20, 2020

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.

@vishaloswal
Copy link

Same thing on Collapse:
image

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

@SumitJadiya
Copy link

Workaround:
Remove strictMode from index.js

@xreider
Copy link

xreider commented Dec 2, 2020

It is not resolved yet

@iamandrewluca
Copy link
Contributor

@xreider do you want to help fixing it?

@manhddse03539
Copy link

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

@chauger
Copy link

chauger commented Dec 10, 2020

Alert is causing this issue for me

@adamf1631
Copy link

switch to <React.Fragment> in index.js

@iamandrewluca
Copy link
Contributor

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

@d3ce1t
Copy link

d3ce1t commented Jan 22, 2021

@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?

@thetric
Copy link
Author

thetric commented Jan 23, 2021

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

@iamandrewluca
Copy link
Contributor

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.

@adamf1631
Copy link

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

@mazharvai007
Copy link

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

Screenshot 2021-02-09 at 9 16 35 PM

@CleverOscar
Copy link

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

@dogukankutluay
Copy link

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

thankx :)

@musasahinkundakci
Copy link

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

@fsogutcen
Copy link

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

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

@dogukankutluay
Copy link

İndex.js dosyasında "<React.Fragment>" i silmek de etkili olabilir.
Bunu çözmek için bu şekilde kullanmayı seçtim; "ReactDOM.render (, document.getElementById ('root'));"

Ama React için acemi olduğum için doğru adımın nasıl olduğundan emin değilim

selamlar , direkt olarak bütün dosyalar için fragment verilmesi en mantıklısı. İhtimale dayalı bir kod aslında. Araştırdım biraz

@sbaechler
Copy link

@iamandrewluca Can the removal of the legacy APIs be part of the 9.0 release?

@Allakazan
Copy link

This issue still are going on ? Isn't unsafe and dangerous to disable StrictMode ?

@bestguy
Copy link
Contributor

bestguy commented Sep 5, 2021

@sbaechler , @Allakazan yes we have an opportunity now with the upcoming 9.x release.
However FYI there are no full time maintainers so any PRs for this off bootstrap5 branch would be appreciated.
(A few of us are helping out to get Reactstrap 9.x Bootstrap 5.x stable and released.)

@bestguy
Copy link
Contributor

bestguy commented Sep 5, 2021

I've updated rtg to v4 in linked PR, but need to test if addresses everything in this issue. I don't see direct usages of old context API, but catching up here..

Carousel looks like still uses legacy context, but the RTG bump will help in most cases. If Carousel can be updated easily before 9.x release we can do it, but seems could also be a point fix after that too. PRs are welcome: https://github.com/reactstrap/reactstrap/blob/master/src/Carousel.js#L27

@bestguy
Copy link
Contributor

bestguy commented Sep 5, 2021

Also updated Carousel context issue in #2268
We'll do another pre release this week for you all to try out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests