Higher-order component which spreads the surrounding WidgetContext's value to the passed component.
import { withWidgetContext } from 'react-union';
or
var withWidgetContext = require('react-union').withWidgetContext;
namespace
: stringNamespace of the widget. See widget descriptor.
data
: objectData passed by the both widget and common data descriptors.
<div id="navigation"></div>
<!-- Widget descriptor -->
<script
data-union-widget="navigation"
type="application/json"
>
{
"urls": {
"home": "www.example.com",
"api": "/api"
}
}
</script>
And somewhere deep down your React component tree:
import React from 'react';
import { withWidgetContext } from 'react-union';
const HomeLink = ({ data: { urls } }) => <a href={urls.home}>Home</a>;
export default withWidgetContext(HomeLink);