Repository navigation
Commit ddc0834
authored
Carousel: subscribe before calling
The lint fix in #211 left the listeners in an effect declared after the one
that calls setApi. Effects run in order, so a consumer that scrolls as soon as
it gets the api (e.g. `setApi={(api) => api?.scrollTo(2, true)}`) moved the
carousel before anyone was listening. The triggers and indicators then stayed
on slide 1. Subscribing first fixes it, with no setState in an effect.setApi (#214)1 parent 89923e1 commit ddc0834
1 file changed
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 112 | + | |
| 113 | + | |
118 | 114 | | |
119 | 115 | | |
120 | 116 | | |
| |||
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
0 commit comments