OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to get elements by tag name of DOM child in React Native?

  • Thread starter Thread starter Nelah
  • Start date Start date
N

Nelah

Guest
I want to get all element with tag 'path' of imported svg to handle animation for it. What is the best way to do this? Thanks!

My code look like this:

Code:
import React, { useEffect, useRef, useState } from 'react';
import MascotDisplay from '@/assets/mascot/4-pandy.svg'

export default function HomeScreen() {
    const svgRef = useRef(null);
    const fadeOut = ()=> {
        // I want to get all <path> of <MascotDisplay> svg to handle animation here
        // my code to animate svg here and need all <path> of svg
    }
    useEffect(()=>{
        fadeOut()
    }[])
}
return (
<View>
    <TouchableOpacity ref={svgRef} onPress={()=>{fadeOut()}}>
        <MascotDisplay width="100%" height="100%" viewBox='0 0 1024 1024' style/>
    </TouchableOpacity>
</View>
)

<p>I want to get all element with tag 'path' of imported svg to handle animation for it. What is the best way to do this? Thanks!</p>
<p>My code look like this:</p>
<pre><code>import React, { useEffect, useRef, useState } from 'react';
import MascotDisplay from '@/assets/mascot/4-pandy.svg'

export default function HomeScreen() {
const svgRef = useRef(null);
const fadeOut = ()=> {
// I want to get all <path> of <MascotDisplay> svg to handle animation here
// my code to animate svg here and need all <path> of svg
}
useEffect(()=>{
fadeOut()
}[])
}
return (
<View>
<TouchableOpacity ref={svgRef} onPress={()=>{fadeOut()}}>
<MascotDisplay width="100%" height="100%" viewBox='0 0 1024 1024' style/>
</TouchableOpacity>
</View>
)
</code></pre>
 

Latest posts

Online statistics

Members online
0
Guests online
2
Total visitors
2
Ads by Eonads
Top