I’ve got the following page component, with a dummy placeholder
div and a textInput
element. Whenever there is a new input, even the placeholder
component is rerendering. I experience slowness for larger pages and this is probably one of the reasons.
I don’t know how the loader works under the hood but I’m surprised about this behavior. Is that intended?
What is the best practice when it comes to adding states to an entire page with dozens of components?
const PlasmicPage = (props: { pageMeta: any }) => {
const { pageMeta } = props
const [value, setValue] = React.useState("")
const onChange = (e: any) => {
const newValue = e?.target?.value
setValue(newValue)
console.log("onChange")
}
console.log("render page")
return (
<PlasmicComponent
component={pageMeta.displayName}
componentProps={{
placeholder: {
render: () => {
console.log("render placeholder")
return <p>hello</p>
},
},
textInput: {
props: {
value,
onChange,
},
},
}}
/>
)
}
“@plasmicapp/loader-gatsby”: “1.0.203”,
“gatsby”: “4.16.0”,
“react”: “18.2.0”,