Allow React.Fragment as children of Frame
Closed this issue · 4 comments
RareSecond commented
I know this example is not the cleanest code, but this code is throwing an error
{(() => {
if (state.screen === "home") {
return <FrameButton onClick={dispatch}>PLAY</FrameButton>;
}
if (state.screen === "overview") {
return (
<>
<FrameButton onClick={dispatch}>PRESS</FrameButton>
<FrameButton onClick={dispatch}>REFRESH</FrameButton>
</>
);
}
if (state.screen === "button") {
return <FrameButton onClick={dispatch}>HOME</FrameButton>;
}
return null;
})()}
⨯ node_modules/frames.js/dist/next/server.js (542:14) @ eval
⨯ Error: invalid child of <Frame>, must be a <FrameButton> or <FrameImage>
at stringify (<anonymous>)
I know I could probably rearchitecture my app to not need it, but I would think it's a use case that should be supported, no?
davidfurlong commented
yeah it could be - just a question of priority. you could also return an array instead of the fragment and it'd work
RareSecond commented
Ah yeah that could also work!
I'm happy to wip up a PR that just uses https://github.com/grrowl/react-keyed-flatten-children instead of the built-in React.Children
if you want.
davidfurlong commented
sounds like a good way to do it
davidfurlong commented
we've changed the API in frames.js v0.9 whereby react fragments are no longer relevant. Thanks for the feedback, closing this