Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I replaced the class component with function, the following warning was reported: #21

Open
codthing opened this issue Apr 19, 2021 · 0 comments

Comments

@codthing
Copy link

image

export const BanerSwiper = () => {

    const BannerWidth = Dimensions.get('window').width;
    const BannerHeight = 260;

    const [images, set_images] = useState(Array)

    useEffect(() => {
        set_images([
            "https://smapse.com/storage/2018/03/admiral-farragut-academy-sport.jpg",
            "https://smapse.com/storage/2018/03/admiral-farragut.jpg",
            "https://smapse.com/storage/2018/03/akademiya-admiral-farragut.jpg"
        ])
    }, [])

    console.log('images:', images)

    const renderPage = (image: string, index: React.Key | null | undefined) => {
        return (
            <View key={index}>
                <Image style={{ width: BannerWidth, height: BannerHeight }} source={{ uri: image }} />
            </View>
        );
    }


    return (
        <View style={styles.container}>
            <Carousel
                autoplay
                autoplayTimeout={5000}
                loop
                index={0}
                pageSize={BannerWidth}
            >
                {images.map((image, index) => { return (renderPage(image, index)) })}
            </Carousel>
        </View>
    );

}
@codthing codthing changed the title 当我将class组件改变了function时候,报以下警告: When I replaced the class component with function, the following warning was reported: Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant