Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useref array of refs

// https://mattclaffey.medium.com/adding-react-refs-to-an-array-of-items-96e9a12ab40c

const itemEls = useRef(new Array())
{items.map(item => (
 <p key={item} ref={(element) => itemEls.current.push(element)}>{item}</p>
))
Comment

useRef Array

/*both useRef({}) and useRef([]) work..*/
import CalendarStrip from 'react-native-calendar-strip';
export default function App() {
const one = useRef({});
 let x= [];
 
function q()
{
   one.current.getNextWeek();
   two.current.getNextWeek();
}

return (
    <View>
    <CalendarStrip 
    ref={(el)=> one.current[0] = el}
      style={{height:150, paddingTop: 20, paddingBottom: 10}} rightSelector={x} leftSelector={x}
    />

<CalendarStrip 
    ref={(el)=>one.current[1] =el}
      style={{height:150, paddingTop: 20, paddingBottom: 10}}
    />
    <TouchableOpacity onPress={()=>q()}>
      <Text>
        Click Me
      </Text>
    </TouchableOpacity>
    </View>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: mui link icon 
Javascript :: delete object not working 
Javascript :: javascript addeventlistener 
Javascript :: javascript example 
Javascript :: get query params from url 
Javascript :: s3.getobject nodejs example 
Javascript :: puppeteer block request javascript 
Javascript :: how to stop overlapping divs to interact with each others click events 
Javascript :: click binding angular 8 
Javascript :: getting cannot call a class as a function 
Javascript :: set number of reducers in mapreduce 
Javascript :: regex checker 
Javascript :: ng-true-value 
Javascript :: javascript array destructuring 
Javascript :: react select remove the loading indicator 
Javascript :: javascript find missing number 
Javascript :: javascript fuzzy search 
Javascript :: variables con nombre dinamico javascript 
Javascript :: prisma decimal 
Javascript :: react hooks update parent state from child 
Javascript :: jquery dom traversal parent 
Javascript :: check if token is expired 
Javascript :: .index of javascript 
Javascript :: js arrow anonymous function 
Javascript :: send response from iframe to parent 
Javascript :: jquery get search parameter 
Javascript :: map and filter js 
Javascript :: recaptcha v3 js 
Javascript :: nextjs starter 
Javascript :: amount into words 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =