Skip to main content
Updated and highlighted the description
Source Link
Sumit Bhatia
  • 5.9k
  • 2
  • 9
  • 25

We can achieve this in one way.

Go to \src\RouteHandler.js\src\RouteHandler.js here sitecore.context will be available.

changeChange the line like below, (This will pass context object to layout)

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js\src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContextsitecoreContext object now.

We can achieve this in one way.

Go to \src\RouteHandler.js here sitecore.context will be available.

change the line like below, (This will pass context object to layout)

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContext object now.

We can achieve this in one way.

Go to \src\RouteHandler.js here sitecore.context will be available.

Change the line like below, (This will pass context object to layout)

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContext object now.

more explanation
Source Link
Andi AR
  • 893
  • 5
  • 22

We can achieve this in one way.

Go to \src\RouteHandler.js here sitecore.context will be available.

change the line like below, (This will pass context object to layout)

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContext object now.

We can achieve this in one way.

Go to \src\RouteHandler.js here sitecore.context will be available.

change the line like below,

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContext object now.

We can achieve this in one way.

Go to \src\RouteHandler.js here sitecore.context will be available.

change the line like below, (This will pass context object to layout)

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContext object now.

Source Link
Andi AR
  • 893
  • 5
  • 22

We can achieve this in one way.

Go to \src\RouteHandler.js here sitecore.context will be available.

change the line like below,

// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;

Goto \src\Layout.js, change the line below

// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {

We can access the sitecoreContext object now.