PLhery / node-twitter-api-v2

Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
https://www.npmjs.com/package/twitter-api-v2
Apache License 2.0
1.31k stars 186 forks source link

Fix ReferenceError: Cannot access 'TwitterApiReadWrite' before initialization #544

Closed devin-ai-integration[bot] closed 2 weeks ago

devin-ai-integration[bot] commented 1 month ago

Fix ReferenceError: Cannot access 'TwitterApiReadWrite' before initialization

This pull request addresses the issue #531 where a ReferenceError occurs when accessing 'TwitterApiReadWrite' before initialization in Next.js with Turbo mode enabled.

Changes made

How to test

  1. Clone this branch and run a Next.js application with Turbo mode enabled.
  2. Use the TwitterApi class to make API calls.
  3. Verify that no ReferenceError occurs when accessing TwitterApiReadWrite.

Additional notes

This solution ensures that TwitterApiReadWrite is initialized when it's first accessed, preventing the ReferenceError in various lifecycle methods and the component body.

Link to Devin run: https://preview.devin.ai/devin/b55d37eda5a34aaaa5809e320711f7d9

This Devin run was requested by Paul-Louis

If you have any feedback, you can leave comments in the PR and I'll address them in the app!