Commit ffe9e69
authored
feat(fix): refactor button instantiation into ButtonWrapper class
The problem is that `new` is being used on something that is not a constructor (likely a function component). The fix is to stop using `new` and instead use `Button` in the manner it is intended to be used. Since the next line calls `button.render()`, it looks like the code expects an instance with a `render` method; to keep behavior similar without changing `Button`'s implementation, we can create a simple wrapper class that internally calls the `Button` function.
The best minimal fix inside `main.ts` is: define a small `ButtonWrapper` class that has a `render` method invoking `Button`, then instantiate that wrapper with `new ButtonWrapper()` instead of `new Button()`. This avoids changing `./button.tsx`, aligns with the intended non-constructor nature of `Button`, and preserves the existing `button.render();` call site. Concretely, in `turborepo-tests/integration/fixtures/turbo_trace/main.ts`, we will insert a `class ButtonWrapper` definition above the `const button = ...` line, change that instantiation to `new ButtonWrapper()`, and leave the `render` call as is. No new imports are required.1 parent 59866f5 commit ffe9e69
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
0 commit comments