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.

Cannot register spotlight action in an effect

See original GitHub issue

What package has an issue

@mantine/spotlight

Describe the bug

If you try to register new actions in an useEffect, this doesn’t work. If you pass spotlight as the useEffect dependency, this is run forever. also if you limit to registerActions and removeActions which probably are incorrectly created and are not callbacks created through useCallback.

The idea is this:

const spotlight = useSpotlight();

  useEffect(() => {
    console.log("register");
    spotlight.registerActions([
      {
        id: "act1",
        title: "Action",
        onTrigger: () => {}
      }
    ]);

    return () => {
      console.log("remove");
      spotlight.removeActions(["act1"]);
    };
    // Try to correctly pass spotlight as dependency here
  }, []);

An use case for this is to register and de-register actions based on external events. e.g. an action to mute/unmute the microphone based on the mute state.

In which browser did the problem occur

Any

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/reverent-leftpad-6i6fkz

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

No

Possible fix

This probably happen because everytime the children of SpotlightProvider change, the initial actions are re-set

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ercgratcommented, Jul 18, 2022

PR #1085 introduced behavior to update the actions whenever the actions prop to SpotlightProvider changes.

@ramiel because you are passing an unmemoized array as the actions prop, when the provider re-renders it thinks your actions have changed and updates actions with the empty array. Dependency checks are always shallow comparisons; the two empty arrays from each re-render are NOT equal. Memoizing the array fixes your sandbox example: https://codesandbox.io/s/vibrant-jennings-ioy752

0reactions
rtivitalcommented, Aug 11, 2022

Fixed in 5.1.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix It When Windows Spotlight Is Not Working on ...
Select the Start menu, type Settings, and choose the Settings app. Select Personalization > Lock Screen.
Read more >
Configure Windows Spotlight on the lock screen
Windows Spotlight is an option for the lock screen background that displays different background images on the lock screen.
Read more >
The Spotlight Effect and Social Anxiety - Verywell Mind
The spotlight effect occurs when we overestimate how much others notice us. It may occur if you have social anxiety. Learn more about...
Read more >
Spotlight Effect: Definition, Examples, and Experiments
Something called the spotlight effect helps explain why you don't need to worry about your faux pas lingering in anyone's memory (except ...
Read more >
Spotlight cannot find Maps app in latest Ventura 13.1 - Reddit
Yes, deleting com.apple.Spotlight.plist followed by a reboot seems to have resolved it. Thank You!
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