You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
It seems href is not working with a state var. Getting a JS error in browser.
Error: Multiple children were passed to <Link> with `href` of `one_value` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children
To Reproduce
Steps to reproduce the behavior:
Code/Link to Repo:
"""Welcome to Pynecone! This file create a counter app."""importpyneconeaspcfromtypingimportDictclassState(pc.State):
my_dict: Dict[str, str] = {"A": "/onevalue", "B": "/anothervalue"}
defindex():
returnpc.link(
pc.text("A"),
href=State.my_dict["A"]
)
# Add state and page to the app.app=pc.App(state=State)
app.add_page(index, title="TableExample")
app.compile()
Expected behavior
Expect it to work as a regular state var reference.
** Specifics (please complete the following information):**
wait - compiling / (client and server)...
event - compiled client and server successfully in 1596 ms (830 modules)
wait - compiling /_error (client and server)...
error - node_modules\next\dist\client\link.js (216:22) @ Object.LinkComponent [as render]
error - Error: Multiple children were passed to with href of https://pynecone.io/docs/getting-started/introduction but only one child is supported https://nextjs.org/docs/messages/link-multiple-children
at Object.LinkComponent [as render] (webpack-internal:///./node_modules/next/dist/client/link.js:216:23)
at ReactDOMServerRenderer.render (C:\Users\Administrator\Desktop\pc_app.web\node_modules\react-dom\cjs\react-dom-server.node.development.js:3872:44)
at ReactDOMServerRenderer.read (C:\Users\Administrator\Desktop\pc_app.web\node_modules\react-dom\cjs\react-dom-server.node.development.js:3690:29)
at Object.renderToString (C:\Users\Administrator\Desktop\pc_app.web\node_modules\react-dom\cjs\react-dom-server.node.development.js:4298:27)
at renderDocument (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\render.js:736:47)
at Object.renderToHTML (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\render.js:819:34)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async doRender (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\base-server.js:687:38)
at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\base-server.js:796:28)
at async C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\response-cache\index.js:80:36 {
page: '/'
}
`
Can you send a snippet of your code or is it the code from above?
source code
"""Welcome to Pynecone! This file outlines the steps to create a basic app."""
from pcconfig import config
import pynecone as pc
docs_url = "https://pynecone.io/docs/getting-started/introduction"
filename = f"{config.app_name}/{config.app_name}.py"
class State(pc.State):
"""The app state."""
pass
def index():
return pc.center(
pc.vstack(
pc.heading("Welcome to Pynecone!", font_size="2em"),
pc.box("Get started by editing ", pc.code(filename, font_size="1em")),
pc.link(
"Check out our docs!",
href=docs_url,
border="0.1em solid",
padding="0.5em",
border_radius="0.5em",
_hover={
"color": "rgb(107,99,246)",
},
),
spacing="1.5em",
font_size="2em",
),
padding_top="10%",
)
# Add state and page to the app.
app = pc.App(state=State)
app.add_page(index)
app.compile()
Activity
picklelo commentedon Jan 9, 2023
I think you can't pass a
pc.text(or any other component) to apc.link. This should work:We should throw an exception in the compiler to catch this to avoid any JS errors.
EDIT: Actually not sure why other components can't be nested, as long as there's only one...
xugaoxiang commentedon Jan 11, 2023
Same error on v0.1.11,python 3.8, nodejs 18.12.1, windows 10 64bit
I use pc init and then pc run, powershell console outputs
`
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
event - compiled client and server successfully in 12.6s (761 modules)
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
wait - compiling / (client and server)...
event - compiled client and server successfully in 1596 ms (830 modules)
wait - compiling /_error (client and server)...
error - node_modules\next\dist\client\link.js (216:22) @ Object.LinkComponent [as render]
error - Error: Multiple children were passed to with
hrefofhttps://pynecone.io/docs/getting-started/introductionbut only one child is supported https://nextjs.org/docs/messages/link-multiple-childrenat Object.LinkComponent [as render] (webpack-internal:///./node_modules/next/dist/client/link.js:216:23)
at ReactDOMServerRenderer.render (C:\Users\Administrator\Desktop\pc_app.web\node_modules\react-dom\cjs\react-dom-server.node.development.js:3872:44)
at ReactDOMServerRenderer.read (C:\Users\Administrator\Desktop\pc_app.web\node_modules\react-dom\cjs\react-dom-server.node.development.js:3690:29)
at Object.renderToString (C:\Users\Administrator\Desktop\pc_app.web\node_modules\react-dom\cjs\react-dom-server.node.development.js:4298:27)
at renderDocument (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\render.js:736:47)
at Object.renderToHTML (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\render.js:819:34)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async doRender (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\base-server.js:687:38)
at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\base-server.js:796:28)
at async C:\Users\Administrator\Desktop\pc_app.web\node_modules\next\dist\server\response-cache\index.js:80:36 {
page: '/'
}
`
Alek99 commentedon Jan 11, 2023
Can you send a snippet of your code or is it the code from above?
Alek99 commentedon Jan 11, 2023
Ah ok I see your on windows we almost have windows support done should have it up soon this is the last error to fix
xugaoxiang commentedon Jan 11, 2023
source code
Alek99 commentedon Jan 13, 2023
Working on this now
Inkee1 commentedon Jan 16, 2023
Same issue. """Error: Multiple children were passed to with
hrefofhttps://pynecone.io/docs/getting-started/introductionbut only one child is supported https://nextjs.org/docs/messages/link-multiple-children"" I installed pynecone today on windows 10, with the example code on pynecone website. https://pynecone.io/docs/getting-started/introductionxugaoxiang commentedon Jan 17, 2023
Error still exists, already update to v0.1.12.