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
Implemented lazy initialization for the TwitterApiReadWrite class.
Modified the TwitterApi class to extend TwitterApiBase instead of TwitterApiReadWrite.
Changed the readWrite property to an async method that ensures TwitterApiReadWrite is initialized before use.
How to test
Clone this branch and run a Next.js application with Turbo mode enabled.
Use the TwitterApi class to make API calls.
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.
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
TwitterApiReadWrite
class.TwitterApi
class to extendTwitterApiBase
instead ofTwitterApiReadWrite
.readWrite
property to an async method that ensuresTwitterApiReadWrite
is initialized before use.How to test
TwitterApi
class to make API calls.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!