Builder.io page redirecting to another builder.io page
- Dominant language
- TypeScript
- Stars
- 8.8k
- Forks
- 1.2k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 17
Description
**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 (
)
```
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.