[MGNLFE-170] Use HOC for Magnolia property mapping (HA) Created: 14/Feb/22 Updated: 25/Mar/22 Resolved: 25/Mar/22 |
|
| Status: | Closed |
| Project: | Magnolia Frontend Helpers |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Mark Wienk | Assignee: | Senol Tas |
| Resolution: | Outdated | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Date of First Response: |
| Description |
|
I created a Higher order component (HOC) to use with React. It is a reusable function that replaces the generated wrapper/builder from the HA generator. I don't see where the ha-cli project is hosted, so can't create a PR for it, but here is my code:
export function withMgnlProps<P extends object>( Component: React.ComponentType<P> ): React.FC<P> { const WithMgnlProps = (props: PropsWithChildren<P>) => { const transformed = transformNode({ ...props }); return <Component {...transformed} />; }; const displayName = Component.displayName || Component.name || "Component"; WithMgnlProps.displayName = `WithMgnlProps(${displayName})`; return WithMgnlProps; } |
| Comments |
| Comment by Christopher Zimmermann [ 25/Mar/22 ] |
|
Closing as outdated - see related ticket. |