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

Version 1.6.2 stops working on react-native 0.74.5 #479

Open
outaTiME opened this issue Aug 27, 2024 · 17 comments
Open

Version 1.6.2 stops working on react-native 0.74.5 #479

outaTiME opened this issue Aug 27, 2024 · 17 comments

Comments

@outaTiME
Copy link

outaTiME commented Aug 27, 2024

Hello there,
a while ago I updated to the new version and it stopped working on react-native 0.74.5, I do not know if it is something expected but at the moment I left forced to the previous version that still works perfectly.

v1.6.1 v1.6.2
CleanShot 2024-08-27 at 20 23 20 CleanShot 2024-08-27 at 20 24 25

See how in the new version (1.6.2) as soon as the screen loads nothing is displayed and should do as seen on version 1.6.1.

Note: ignoring the warning below is a behavior of my application.

@oblador
Copy link
Owner

oblador commented Aug 28, 2024

Hmm, probably caused by #475

Do you have a small reproduction of this issue?

@18jad
Copy link

18jad commented Aug 28, 2024

Same for me I had to downgrade to 1.6.1 for it to work again

@nlarif
Copy link

nlarif commented Aug 29, 2024

Same issue for me 1.6.2 is no longer working with Expo 51

@thehellmaker
Copy link

Same Issue for me

@Abdulazeez-98
Copy link

Abdulazeez-98 commented Aug 31, 2024

Same issue for me. It occurred after I updated to Expo 51 SDK (react native 0.74).
The issue is exactly the same as the OP. The view is not rendered initially (when 'collapsed' is set to false), you must set it to true then to false for it to show the content.

@oliviercperrier
Copy link

Same issue with 1.6.1. if collapsed is default to true, content is not expanded. This was working before upgrading to react-native 0.74.5

@nijatkazimliPG
Copy link

Had to rollback to 1.5.2. (You might lose some features).
NOTE:
Expanding and collapsing very quickly will throw an error: this.contentHandle.getNode() is not a function.
The ref is basically is the reference to Animated.View, for which getNode() does not work anymore. Instead you can call .measure(...) directly on the ref. So, you should patch the package.
From:
image
To:
image

@ElicaInc
Copy link

ElicaInc commented Sep 8, 2024

Same issue for me on react-native 0.73.9 with 1.6.2. 1.6.1 works well.

@truph01
Copy link
Contributor

truph01 commented Sep 9, 2024

RCA:

In

height: hasKnownHeight ? height : 0,

Height will be 0 if hasKnownHeight is false. But hasKnownHeight is true only when users expand options (collapsed change from true to false)

this._toggleCollapsed(this.props.collapsed);

In case the collapse is false initially, we should show the content, but we don’t have the logic to measure content -> hasKnownHeight is false -> height is 0

Solution:

We should trigger _toggleCollapsed in componentDidMount or _handleLayoutChange if this.props.collapsed is false

  componentDidMount(){
    if(!this.props.collapsed){
      this._toggleCollapsed(this.props.collapsed)
    }
  }

@truph01
Copy link
Contributor

truph01 commented Sep 10, 2024

@oblador What do you think about my solution above?

@Kreshnik
Copy link

Same issue.

@Pujan92
Copy link

Pujan92 commented Sep 14, 2024

In case the collapse is false initially, we should show the content, but we don’t have the logic to measure content

@truph01 I agree with the RCA, initially we don't have a logic to measure the content height and due to that height will remain 0 initially.

componentDidMount(){
 if(!this.props.collapsed){
   this._toggleCollapsed(this.props.collapsed)
 }
}

As proposed I think either we need to call function _toggleCollapsed or we can call _measureContent to avoid animation.

@truph01 can you plz raise a PR, @oblador will review it there.

@truph01
Copy link
Contributor

truph01 commented Sep 17, 2024

@oblador @Pujan92 PR is ready to review

@hvq1919
Copy link

hvq1919 commented Sep 23, 2024

RCA:

In

height: hasKnownHeight ? height : 0,

Height will be 0 if hasKnownHeight is false. But hasKnownHeight is true only when users expand options (collapsed change from true to false)

this._toggleCollapsed(this.props.collapsed);

In case the collapse is false initially, we should show the content, but we don’t have the logic to measure content -> hasKnownHeight is false -> height is 0

Solution:

We should trigger _toggleCollapsed in componentDidMount or _handleLayoutChange if this.props.collapsed is false

  componentDidMount(){
    if(!this.props.collapsed){
      this._toggleCollapsed(this.props.collapsed)
    }
  }

Thank you so much.

@sentry0
Copy link

sentry0 commented Sep 29, 2024

Here is a diff based on the PR @Pujan92 was kind enough to file.

index dc4d3b8..d69d1e7 100644
--- a/node_modules/react-native-collapsible/Collapsible.js
+++ b/node_modules/react-native-collapsible/Collapsible.js
@@ -53,6 +53,12 @@ export default class Collapsible extends Component {
 
   contentHandle = null;
 
+  componentDidMount() {
+    if (!this.props.collapsed) {
+      this._measureContent((height) => this.state.height.setValue(height));
+    }
+  }
+
   _handleRef = (ref) => {
     this.contentHandle = ref;
   };```

@acidealista
Copy link

In my case, I encountered a crash when rotating the device to landscape mode under specific circumstances. The crash occurred if I opened a modal from the page where the accordion component is used, and the modal supports landscape orientation. To prevent this, I had to add an additional check to the patch. Without this fix, rotating the device while the modal is open causes the app to crash.

+  componentDidMount() {
+    if (!this.props.collapsed) {
+      this._measureContent((height) => height != null && this.state.height.setValue(height));
+    }
+  }
+

@jadonhansen
Copy link

Experiencing the same with 1.6.2 and RN 0.72.3 and Expo 49.0.5.
Downgrading to 1.6.1 worked for me.

Not sure why @oblador is ignoring this PR though...

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