Hello, I am making some progress with Frontity (and having some fun on the side).
1 - How should I process to be able to use the react routers for links in template parts from WP? I have created one for the nav and one for the footer and would like have the Links without any reloading of the page. Is that possible? FIXED -> Used a processor
2 - I am getting this undefined error quite a lot. Any ideas what the problem could be?
the code:
import { connect, styled } from "frontity";
import { fixedHeaderStyles, headerStyles } from "./header-styles";
import Link from "./../link"
let StyledLogo = styled.img({
'max-height': '120px',
'max-width': '300px',
'padding-top': '5px'
})
const FixedHeader = ({ state, libraries }) => {
// Get the header template.
const data = state.source.get("/wp_template_part/navigation/");
const header = state.source["wp_template_part"][data.id];
// Get the component that transform the template to React.
const Html2React = libraries.html2react.Component;
const { isFixedHeaderVisible } = state.theme;
const url = "/";
return (
<div css={fixedHeaderStyles({ state, isFixedHeaderVisible })}>
{/* Render the template */}
<Link link={url}><StyledLogo src="http://frontity.hei-schule.ch/wp-content/uploads/2020/07/hei_logo-1.jpg" alt="logo" /></Link>
<Html2React html={header.content.rendered} />
</div>
);
}
export default connect(FixedHeader);
the error:
TypeError: Cannot read property 'undefined' of undefined
at FixedHeader (webpack-internal:///./packages/hei-theme/src/components/navigation/index.js:9:107)
at runAsReaction (webpack-internal:///./node_modules/@frontity/connect/src/reactionRunner.js:16:45)
at reaction (webpack-internal:///./node_modules/@frontity/connect/src/observer.js:7:131)
at eval (webpack-internal:///./node_modules/@frontity/connect/src/connect.js:21:16)
at processChild (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:397:2319)
at resolve (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:396:122)
at ReactDOMServerRenderer.render (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:433:1199)
at ReactDOMServerRenderer.read (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:433:55)
at renderToString (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:470:116)
at eval (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:53:243)