question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_slider1Ref in a function component

See original GitHub issue

How can I access this._slider1Ref in a function component and not in a class? <Carousel ref={c => this._slider1Ref = c} />

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

4reactions
aldeboutcommented, Sep 20, 2019

I use the useRef hook.

I’ve not been able to type it correctly though, it works but with warnings, I don’t know if it’s an issue with my code or the typings.

2reactions
maartenvandillencommented, Apr 23, 2020

mine seems to be happy with this:

const carouselRef = useRef<Carousel<ICarouselData> & ScrollViewProps & CarouselStatic<ICarouselData>>(null);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the Effect Hook - React
The Effect Hook lets you perform side effects in function components: import React, { useState, useEffect } from 'react'; function Example() { const...
Read more >
Function Components - React TypeScript Cheatsheets
Function Components. These can be written as normal functions that take a props argument and return a JSX element. // Declaring type of...
Read more >
React Function Components
This in-depth guide shows you everything about React Function Components -- which are basically just JavaScript Functions being React Components ...
Read more >
React - How to force a function component to render?
Using react hooks, you can now call useState() in your function component. useState() will return an array of 2 things: A value, representing...
Read more >
How To Convert React Class Components to Functional ...
In this tutorial, we'll look at five ways to convert React Class Components to Functional Components using React Hooks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found