A
A
ajlee42021-07-04 13:24:07
React
ajlee4, 2021-07-04 13:24:07

Pass jsx to prop?

Please tell me how can I pass jsx to the prop for example:

const A = ({children, footer}) => (
                <View>
                    {children}
                    <View>
                        {/*тут условно какая-то супер-крутая верстка для футера*/}
                        {footer}
                    </View>
                </View>
            )
            
            const B = () => {
                const footer = () => (
                    <View>
                        <Text>
                            footer
                        </Text>
                    </View>
                )
                return (
                    <View>
                        <A footer={footer}>
                            <Text>
                                lorem
                            </Text>
                        </A>
                    </View>
                )
            }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2021-07-04
@abberati

const B = () => {
                const footer = (
                    <View>
                        <Text>
                            footer
                        </Text>
                    </View>
                )
                return (
                    <View>
                        <A footer={footer}>
                            <Text>
                                lorem
                            </Text>
                        </A>
                    </View>
                )
            }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question