I am trying to write multiple components in a single .jsx
file. But for some reason it doesn't work in React 18. It was working fine in the previous Versions. But when i create a separate .jsx
file for the component and import it, it works. Following is an example code:
const ChannelListContainer = () => {
return (
<>
<Sidebar logout={logout} />
<div className="channel-list__list__wrapper">
<CompanyHeader />
<ChannelSearch />
<ChannelList
filters={{}}
channelRenderFilterFn={() => {}}
List={(listProps) => <TeamChannelList {...listProps} type="team" />}
Preview={(previewProps) => (
<TeamChannelPreview {...previewProps} type="team" />
)}
/>
<ChannelList
filters={{}}
channelRenderFilterFn={() => {}}
List={(listProps) => (
<TeamChannelList {...listProps} type="messaging" />
)}
Preview={(previewProps) => (
<TeamChannelPreview {...previewProps} type="messaging" />
)}
/>
</div>
</>
);
};
The sidebar component imported in the above code was first meant to be in the same file. But i had to create the Sidebar component separately to use it. How can i write two components in the same .jsx
file and use them in React 18?
foo
bar
>` it works and now it doesn't? That would be an inexplicable, breaking change to the JSX processor. – Dave Newton Apr 10 '22 at 23:04