H
H
herasko-sg2021-10-01 16:08:43
React
herasko-sg, 2021-10-01 16:08:43

React how to render multiple elements in one JSX element?

I have a functional theme component that is a theme provider (AppThemeProvider) and a separate AppThemeButton component to change the theme. It is possible to place these 2 components in one (AppTheme) so that when writing AppTheme.Provider, the theme provider is returned, and when writing AppTheme.Button, the theme change button. It is desirable that this component be functional, not class-based.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-10-01
@herasko-sg

AppTheme.js:

import AppThemeProvider from './AppThemeProvider.jsx';
import AppThemeButton from './AppThemeButton.jsx';

export default {
  Button: AppThemeButton,
  Provider: AppThemeProvider
}

Yes, this is normal javascript, it has nothing to do with react.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question