builder icon indicating copy to clipboard operation
builder copied to clipboard

Builder.io page redirecting to another builder.io page

Open tomasamado97 opened this issue 4 years ago • 1 comments

Describe the bug When using custom code to navigate between routes, if I'm in a builder.io route and push to another builder.io route, even though we ask for a different urlPath to builder, we get back the initial page again.

To Reproduce Steps to reproduce the behavior:

  1. Create a page with a button with custom code, where we call state.link(pageUrl), pageUrl must be a different page but a builder page
  2. Add the custom code on the page data, in the builder component
  3. Land on the new page
  4. Click on the button
  5. No content change

Expected behavior I should see the page that uses pageUrl for the path

Screenshots Cannot post screenshots due to company policies.

Additional context The custom code for state.link only grabs the route and pushes using react-router this avoid an entire app reload. (If you use a Link or an anchor the entire app reloads causing a cascade of re-renders and requests)

const history = useHistory();

 const data = {
     link: (route) => history.push(route)
}

useEffect(() => {
        builder.get('page', { userAttributes: { urlPath: location.pathname } })
            .promise().then((page) => {
                if (page) {
                    setPage(page);
                } else {
                    history.replace('/error');
                }
            })
    }, [location.pathname])

return (
    <BuilderComponent
          model="page"
          content={pageData}
          data={data}
      />
)

We also tried using builder.get('page', { url: location.pathname })

While debugging I found that the pathname that we send its the correct one, but the page that we get back is still the current one instead of the new one.

tomasamado97 avatar Nov 04 '22 18:11 tomasamado97

can I get some updates in this issue? @manucorporat

tomasamado97 avatar Nov 11 '22 17:11 tomasamado97