question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add viewContext for all top-level React apps

See original GitHub issue

Feature Description

The Root component that we use for all top-level React apps has a viewContext prop that was introduced initially for providing view/screen context for feature tours. It was later also integrated with our ErrorHandler (boundary) to provide more contextual error codes for tracking React errors.

However, the prop was initially optional because we only needed feature tours in a few select places so it didn’t make sense at the time to define this in all instances. For errors however, we do see these raised on all screens (for one reason or another) and this results in less contextual error codes because it has null where there would otherwise be a named view context.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The viewContext prop of the Root component should be promoted to be a required prop
  • View context constants should be added for all missing contexts (please list in IB)
  • All instances of Root missing this prop should be updated to provide it via the respective constant

Implementation Brief

  • In assets/js/components/Root, add the isRequired flag to the propType declaration of the viewContext prop
  • Go through the following list, and for each item:
    • Add the constant name to assets/js/googlesitekit/constants.js
    • Import the constant to the file and pass it as the viewContext prop to the Root component
File Constant
assets/js/googlesitekit-user-input.js VIEW_CONTEXT_USER_INPUT = ‘userInput’;
assets/js/googlesitekit-activation.js VIEW_CONTEXT_ACTIVATION = ‘activation’;
assets/js/googlesitekit-dashboard-splash.js VIEW_CONTEXT_DASHBOARD_SPLASH = ‘splash’;
assets/js/googlesitekit-adminbar.js VIEW_CONTEXT_ADMIN_BAR = ‘adminBar’;
assets/js/googlesitekit-settings.js VIEW_CONTEXT_SETTINGS = ‘settings’;
assets/js/googlesitekit-module.js VIEW_CONTEXT_MODULE = ‘module’;
assets/js/googlesitekit-wp-dashboard.js VIEW_CONTEXT_WP_DASHBOARD = ‘WPDashboard’;

Test Coverage

  • No new tests required.

Visual Regression Changes

  • Unlikely that any images will need updating.

QA Brief

  • Verify that the Root component’s viewContext prop is now required.
  • Verify that wherever the Root component is used in the codebase, a viewContext prop is provided.
  • Verify that the correct constant is passed in each case, and that the respective constant is in assets/js/googlesitekit/constants.js.

Changelog entry

  • N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
felixarntzcommented, Jul 28, 2021

@aaemnnosttv That’s a good idea for the future. We also already decided that a widget context will be used per tab, so it could be similar for the view context.

1reaction
johnPhillipscommented, Jul 27, 2021

No problem @eugene-manuilov I often end up sketching in a solution in order to understand the issue / generate the IB, so in this case I just committed what I’d done as it was fairly trivial in the end. I’ll hold off next time unless I’ve run it past one of the senior devs first 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooltip tours #2649 - google/site-kit-wp · GitHub
Epic for implementing tooltip-based tours for e.g. a specific feature (after updating to the version where it was added) or an entire ...
Read more >
In which order are React components re-rendered when ...
In which order are React components re-rendered when global state is updated through hooks? · 1 · You can check it by adding...
Read more >
view-context - Web Synth
A view context (often abbreviated vc in web synth code) is the name for one of the top-level [module]s of the web synth...
Read more >
React on Rails - Shakacode
First, you should have a /config/webpacker.yml setup. Here is the setup when using the recommended /client directory for your node_modules and source files:....
Read more >
ViewGroup - Android Developers
android:clickable, Defines whether this view reacts to click events. ... android:onClick, Name of the method in this View's context to invoke when the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found