Wrapper components

D
Apr 7, 2024

Sometimes there are situations where you find yourself repeating the use of components in ReactJS. At times like this it might be useful to use a component wrapper to help you out.

An example of this could be as follows:

import Modal from '@mui/core'

const ModalWrapper = (props) => {
return (
<Modal>
<Box>
{props.children}
</Box>
</Modal>
);
};


const MyComponent = () => <p>Hello World!</p>;


<ModalWrapper>
<mycomp />
</ModalWrapper>

This lets you go about creating reusable component wrappers for your individual components.

Cheers!

--

--

D

An aspiring Robotics Researcher. I am currently in my 4th year of undergraduate studies. I am working on optimising the ROS navigation packages. Follow 4 more!