akiran / akiran/react-slick

Is forwardRef going to be implemented ?

Aperta
#1,821 2 commenti 12 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
11.9k
Fork
2.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Currently using **Next.js** for a project, and I am trying to use the new Dynamic Import with the Slider (react-slick) component to create a separate chunk.

The problem is that I need to forward the ref to be able to use a custom Next & Prev button.
React has a new API to allow that, [forwardRef](https://reactjs.org/docs/forwarding-refs.html#forwarding-refs-to-dom-components)

**Steps to replicate :**
1 - First I need to Dynamically Import react-slick :
```jsx
const DynamicSlider = dynamic(() => import('react-slick'))
```
2 - Then use the forwardRef api :
```jsx
const ForwardedSlider = React.forwardRef((props, ref) => (

{props.children}

))
```
3 - And use ForwardedSlider :
```jsx

slider content

```

Even if my component is rendered, I can't access to the object 'myRef' and can't use my custom buttons

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.