Handling an error with onClick event in React

This week I had an issue with a react component that took a little time to debug. There did not seem to be any good explanations as to what was happening, so I thought I’d write it up in case someone is googling to find a solution.

Component and desired behavior: 

The component was created to provide custom controls on a video using the <video> element provided by html5. Within the react application there is a reference created to the video element which is passed in via a context provider.

The desired behavior is to have both mouse click actions, including: play, pause, forward, rewind. It was also desired to have keyboard commands, include allowing the space bar to play/pause and forward/back arrows to forward/rewind.

The observed bug:

  • If you pressed the space bar to play / pause, everything worked.
  • If you clicked on the play / pause icons, everything worked.
  • If you pressed the space bar to play, then clicked the pause button, everything worked.
  • If you clicked the play button, then pressed the space bar, it did not work.

Essentially anytime you tried to go from the click event to the keyup event, the behavior did not work as expected.

The solution: 

After some reading up on the react docs: React Synthetic Events and gaining some insight on how the events were bubbling up within the application , I placed some console.log statements to get an understanding what was occurring.

What I noticed was that when you pressed the space bar then clicked the play or pause icon, I’d see:  “playing via spacebar” followed immediately by “pausing via mouse click”.

What now seems fairly clear, here is what happened:

  • clicking the icon moved the focus to that element
  • pressing the spacebar triggered the appropriate play/pause command
  • However, because the focus was still on the icon the spacebar was also triggering the onClick event.

Prior to figuring this out, I had tried several attempts at using stopPropogation() or stopImmediatePropogation(), although after seeing the results of the console logging, I realized I just needed to stop behavior of the spacebar causing the onClick to fire.

A couple preventDefault() statements and everything is now working as intended.

Here is the working solution:

WorkingSolution

Advertisements

My reverse fundraising campaign for the Boston Marathon.

Over 10 years ago I spent a season as the running coaching for a Team in Training team. It was a great experience. I met a bunch of great individuals, many of those people accomplished their goal of running a 1/2 or full marathon and they raised money for the Leukemia & Lymphoma Society. Team in Training was the first highly scaled and successful fundraising program, which used endurance events as their tool.

Today, I’m excited to see the progress that the team at Moolathon is doing in that space.

When I decided to run the Boston Marathon in 2020, I knew I wanted to use it for something personally rewarding beyond my own running goals.

However I have a personal appreciation to start a fundraising campaign as social media is overwhelmed with different ways individuals are trying to raise money. Facebook has made every birthday a fundraising event.

This is when I decided do a reverse fundraising campaign.

What is a reverse fundraising campaign?

  • It is something I think I just made up?
  • Instead of soliciting donations, I am going ask for suggestions on who I should donate to.
  • Who will I give my money to?
    • I do not have any limitations right now. I will give to an organization that you suggest. I will give it directly to someone that has a need and could use the money. I will give it to you, if it makes sense.
  • What are the requirements?
    • We will need to be connected via a social media platform so we can communicate privately: Instagram, Facebook, Twitter
    • You will need to share a campaign link so I can make a donation  or you will need to have a cashapp account so I can send the funds directly.

What am I giving away?

  • Every Friday between now and the marathon (4/20/20), I will give $26.20

Why?

  • As noted, I wanted the Boston Marathon to be more than about my personal running goals.
  • I have been inspired by watching Bill Pulte use twitter to spread love and money.
  • Money is one of those things I have associated a scarcity mentality to. At times, I do ok, other times it becomes a major barrier for me. In 2019, I had a goal to monthly give money to two organizations, I did occasionally but not consistently. The growing desire to hoard and take is a current problem. As a small business entrepreneur, I’m often waiting for the next phase of stagnant growth or no revenue (or worse). It’s just how I am hard wired. Doing this is one way to change my own mindset and behavior. I realize that $26.20 is not going to change things, but hopefully it helps someone with their campaign, goes toward a pair of shoes for someone to exercise in, a healthy bag of fruit from the grocery or even a race entry for a local 5k? I will paraphrase Bill Pulte from his twitter account, I am simply one person, but together we can change everything.

 

 

Peak Experiences: Words & Moments

I sat in the coffee shop on a Sunday afternoon hacking away on a client’s project. I received a text message that was a little cryptic,

“Can I tell you something?”

Anxiously and with hesitation, I said “sure”. What followed was one of the more kind and uplifting things someone has said to me within the past year.

We sat at the stop light and the tension was heavy. After arguing most the of the car ride, I yelled out something that should not have been said. It was said in frustration, with anger and with the intention to cause pain. That pain was hidden and never dissipated.

These are just two experiences that have lead me to start using a phrase repeatedly,

“words matter”

I say it a lot. I encourage others that I have influence on to consider it. But I primarily want to embed this truth into my own consciousness and behaviors.

I have always understood that words were important. I remember sitting down and writing a lengthy letter to my parents listing all the reasons why I should not move away from Broken Bow, Nebraska during my junior year. It was the first example where I saw that words had power.

My struggle for many years was figuring out how to use my voice to share positive words that mattered.

Words matter and the power of moments can change an individual’s life.

As I ran across the finish line of the 1999 Lincoln Marathon, I was devastrated and proud at the same moment. I was tired yet energized. I had more joy than I had experienced in months, but wanted to cry. Little did I know, that moment would shape my professional and social life for the next twenty years.

I have been reading the book, The Power of Moments by Chip and Dan Heath, learning about the characteristics of a powerful moment. Moments that have the potential of becoming peak experiences have these four characteristics:

1. Some elevation of sensory pleasures or surprise.
2. Provide insight and rewire the idea of ourselves.
3. Create pride through acts of courage and achievement.
4. Provide connection with others and social satisfaction.

As I have been molding all these lessons into knowledge and cross referencing my experience, I have come to the following conclusion:

When you match the right words with the right moment, you can create memories that are unforgettable. This is important as our memories are a string of loosely tied together moments, opposed to a true recording of everything that happened.

The following is just an outline of thoughts I have had on this topic.

The good and bad: this powerful experience can create both good and bad memories, so it is as critical to understand how to avoid the bad as it is to create the positive.

Vulnerability: due to Brene Brown, I have spent a lot of time practicing how to be more vulnerable over the past few years. It has greatly impacted my ability to share with others positive words of affirmation. I often feel exposed and vulnerable when voicing affection or even praise for others. This has been a recurring topic in therapy.

Some words you can not take back, therefore; think before you speak: I remember stupid things I have said out of anxiety, anger and pride. The people I said them to often remember also. Even when there is forgiveness, the scares often remain.

Praise is a better teaching tool than criticism: Do you remember a teacher who provided praise, then suggestions on how to improve. How about a teacher who started with the criticism and expectations? Who inspired you? I am my own worst critic, as are most people their own. I am learning to lead with praise.

Random moments and words: The surprise of a positive message. The adventure of an unplanned experience. Those are the types of words and moments that have the opportunity to create something significant. When it feels manufactured, it doesn’t really work. In The Power of Moments, they share the “Employee of the Month” example. The winner of the award rarely feels special.

Seek adventure: it becomes very difficult to create impactful moments when things become routine. Find ways to challenge yourself. Ideally, find others to join you on those adventures.

Slow down time: the book talked about one reason that time seems to speed up as we age is due to the fact that novelty becomes less commonplace. We have less moments. This aligns with the last note, do not let your age decrease your ability or desire to seek adventure.

Practice giving complements: I find it easy to give complements in those moments that are socially expected. This happens after races, major accomplishments, etc. I have begun to practice giving praise for things that do not often receive it. It honestly feels difficult at this point, but I am working on it.

Keep your candor: there was a period (and I still hear it), where people talked a lot about being candid in their communication. It was often a signal that someone was about to be an asshole. I know of this well! I regularly masked my ego and jerkness in the blanket of ‘being honest’.

How I plan to implement this in 2019?

I have been trying to figure out what 2019 is going to be for me. The last few years have been very random, but in directed ways. For example, I never thought I would have created a software development company. However, I was focused on becoming better at the technical side of product development and working with high quality people. It just so happened Ventre Tech was born.

In that spirit, I plan to set my sails in the following directions:

  1. More travel and novelty.
  2. Creating some goal around a habit associated with gratitude, specifically expressing that gratitude.
  3. I’ve become plenty vulnerable with my feelings and emotions, but I need to continue practicing praise.

Ultimately, I’d like to have at least 10 powerful moments in 2019. As I think back on 2018, I can think of 6 or 7 moments, most are positive with one being negative. When I think about those moments, I image two of them will remain lasting peak experiences and memories. One of the positive moments and the negative moment. The elements they both have in common are words that stick, elevation of sensory, surprise and they lead to new personal insights.

I would love to hear your thoughts.

3 of many variables associated with new relationships.

Person, time and place

I sat in Joe the Therapist’s office and began asking questions. They were not directed towards him, but questions I wanted the answers to that I couldn’t answer for myself. It all distilled down to this single query:

“What am I missing?”

As we talked through many versions of what that question could mean, he made an observation.

“All those situations had nothing to do with you.”

It was an easy statement for him to make, but an impossible one to accept.

The focus of the discussion was on starting, building and maintaining intimate relationships. As we talked through various attempts, it became even more evident to me that “had nothing to do with you” was a false understanding.

It did not help that I had just turned 40 and was not feeling proud that I was still trying to discover these secrets.

There is clearly a fair amount of emotion and self acceptance I have to dig through regarding this subject. However, I happened to be in a place where I was rethinking this question. This lead me to sit down and start writing. In that moment I realized that successful relationships almost always have three required components.

These three components seem obvious, but worth sharing as I work to clarify my own thoughts. They are: person, time and place.

Person.

It feels lazy to assert that a long term relationship requires two people who mutually believe the other is right for them. I can think of some relationships where the partners know they are with a person that is not right, but maintain the relationship for many different reasons. My observation is that those relationships are rarely healthy.

The challenge is answering the question, “Is he/she the right one?”

This seems even more difficult in a world where online dating is more common then not. This is not because online dating is horrible or even undesirable. It is because as you scroll through pages of profiles and swipe left and right, it gives the illusion that there is an endless pool of options.

This unlimited number of potential partners has meant, at least in my experience, that at the first hint of someone ‘not being the one’ results in a rapid return to scrolling and swiping.

There is also the challenge relationships face when a person was the right person, but as people evolve and change, they no longer seem to satisfy the criteria. This requires the couple to answer a different question: “Is it worth building a new relationship with this evolved individual, or should we start new with someone else?”

The statistics show that 40 to 50 percent of marriages end in divorce (apa.org), therefore it’s safe to say that when faced with this question a majority of the couples decide to move on to someone different.

The romantic in me believes in the idea that there’s an opportunity to find someone that is the right person for all the remaining years. I know it happens, but I have no data to know how large or small that percentage is.

When I evaluate the three variables, I strongly believe that understanding if the person is the ‘right one’ is by far the most difficult of them all. I also believe that once you determine that someone is not the right person, it is the easiest of all the reasons to stop moving forward.

When trying to understand if a specific person is who you should be with, there are no guarantees, but there is hope.

Time.

The phrase “timing is everything” could not be more true than in developing lasting relationships.

When you combine the time and person variables things get complicated. Let’s assume that a couple has discovered that they have found someone they are compatible with, if the timing is off for one of the two, it can be very difficult.

The timing can be off for many reasons, such as:

– One of them is not ready to enter a relationship.
– One or both of them are in an existing relationship.
– One is ready for a relationship, but wants to enter the relationship on a different timescale than the other.

My belief is that this reality is the most difficult of all the observations. The romantic side of my brain believes that ‘love can conquer all’, that if you have found the right person, you will also find a way to make it work.

When I review my experiences, I can identify times that it was simply not the right time.

Place.

What if you have found the right person and the timing is right but the place is wrong? I put place as the third variable because I see this one as the easiest of the three to overcome. I hear stories of people relocating to be with someone.

That being said, it is also a factor that is not negotiable for some. It could be due to aging parents, children in school or they live next to amazing running trails and those are of greater importance (I’m only half kidding).

Final thoughts.

I am clearly not an expert in relationship building. In fact, the evidence would point to the fact that I am not very good at it. However through those failures and as a result of those failures, I spend a fair amount of time in self reflection asking myself “What am I missing?”

Maybe Joe the Therapist is correct in saying that I am not missing anything and that it is just a matter of not aligning these three variables.

I know for a fact that there have been attempts to date those who were the wrong person. It has been the most common missing attribute. I believe that there have been a few people over the last 20 years that were possibly the right one, but at the wrong time. (Does the Garth Brooks song Unanswered Prayers start playing in your head here too?). I also believe that place might be an issue (I do find myself expanding my desirable distance on the dating apps each time I give them a try?), but it is challenging to know when place needs to be overcome.

In closing, the only thing I know for certain is that the next time Joe the Therapist and I meet, I will get my money’s worth as we dig deeper into these seemingly obvious yet challenging observations.

Let’s Divorce – Working to increase happiness amid this emotional process.

I spend a lot of time thinking about my legacy and what that means. It impacts the way that I approach my utilization of time, what projects I want to work on and who I prioritize spending time with. I would like to think that every decision is run through this legacy filter, but it is more correct to say that it’s a guiding light.

Using this approach to decision making the past couple of years has been interesting for many reasons. One of those reasons being a decision to start a company with a couple partners. The baseline for my decision to join was an alignment in how we were going to approach building a company. There was a product that we wanted push forward, but we also shared a desire to help others take their business ideas and launch them into the marketplace. We knew it would take time to figure it out and were interested in taking multiple shots.

One of the guiding lights in my personal life is to work on projects and start businesses that can help lead individuals to happier and healthier lives. I am most fulfilled when this means helping people reach the edges of their personal performance potential.

I am also committed to the idea that helping people find physical health can establish behaviors that supports their emotional, spiritual and mental health.

All of this is context to share the most recent project that I have been working on. About ten months ago, my team was approached with an opportunity to help create technology that would support people getting a divorce.

Internally I asked, “How can divorce be something that creates happiness or health?” Everything I have ever read about divorce is that it is stressful. In fact, it is often cited as one of the most stressful events in a person’s life, right up there with the death of a loved one and having a child.

A little more context for the story.

In a somewhat cruel twist to the plot, it was also during this time that I was finalizing my own divorce. After several years of knowing my marriage was struggling, two and a half years of therapy and then almost a year of slow progress on getting the paperwork completed, I was becoming a divorcee the same month that this business proposal came.

Through my divorce, one of the observations that I consistently had was that I was a lucky man. During the entire process, my ex wife and I got along quite well. We did not fight over possessions and there were no battles about who was wronged the most. We continued to understand that it was a difficult phase for both of us and worked to make it less painful. I knew that this was rare. Our therapist commented many times that he couldn’t believe how well we treated each other.

To completely understand how surreal it was, when we started talking to recently divorced individuals about their experiences, I asked my ex if she would be willing to be interviewed. She was very unselfish and agreed to meet with my business partner. The day they met happened to be the day we got our decree back from the court that our divorce was final.

Back to the story of the product.

When we sat down and talked about the vision for the product, I started to become more intrigued. The story was not about how we could automate divorce, make divorce easier, or make divorce cheap. The discussions were about how we could make divorces less contentious, less litigious and more cooperative. We began planning out how we could begin making progress in this direction and I started talking to recently divorced individuals.

In these discussions, I learned a lot about the experience that others had gone through. There was a lot of fear regarding what had to be done. This included relationship issues and communication with their spouse during the process. There was a large amount of fear about how to go through the process because information was difficult to find. Then there was the realization that financial statuses were going to be impacted, which included the division of assets along with the cost of attorneys.

When you put all of these fears and anxiety on top of the sadness, stress and broken hearts, it becomes a very difficult time for everyone.

I never talked to anyone who said that they got married with the anticipation that one day they would get divorced. Some shared that they got married and looking back probably should not have (which I guess might seem obvious at this stage), but hindsight is 20-20. The point being that no matter what lead to this place in the individual’s life, regardless of the circumstances, divorce is never easy.

This is the observation that allowed me to become more invested in the online divorce platform, LetsDivorce.us.

If I could find a solution that was able to eliminate divorce, I would work on that today. But when you look at the divorce rates across demographics and throughout the U.S., it’s pretty clear that as long as marriage is around, divorce will be also.  

I accepted that this was the reality. I had to also admit that the amount of lost joy and unhappiness experienced was significant. If there was a way to make divorces better, than I could significantly improve people’s lives. There might also be an opportunity to help couples start working through the process, with the support and guidance they need, which leads them to reconciliation?

How does a better divorce happen? That is what we’ve committed to work on. Today, it is starting with one piece that many of those we interviewed identified as a high stress component. And I’m happy to share that The Johnson Law Group is the first customer who is going to be utilizing the LetsDivorce.us solution to help make divorce better.

Growing stronger through vulnerability

When I think about strength, I have several images embedded in my mind. The first one is of my grandfather on a horse. The horse is rearing up and if memory serves me well, the horse is on one leg. This image is iconic. It embodies the ruggedness and toughness that a cowboy has to possess to thrive. When you grow up in the Sandhills of Nebraska, there are many men you can look at who possess these character traits.

As a boy in Nebraska, if the cowboy persona is not what you learned it meant to be a man, then it was likely that you understood a man was epitomized by a football player. It was Tom Osbourne. It was Husker Power. Osbourne was characterized by his stoic demeanor. He had the same emotional expression after a tough loss to Oklahoma as he did after destroying Florida for a National Championship. Husker Power was about developing physically dominating players.

The underlying observation I made as a young man was that being a man required being strong. To be strong meant displaying the characteristics of those cowboys I saw or the players and coaches we admired.

There are many nuances within those two personas that could be titrated out. Things such as:

  • never let them see you hurting
  • boys do not cry
  • keep your problems to yourself
  • do not depend on others, be self sufficient
  • have an answer to solve your problems
  • do not allow your opponent to see your weaknesses

Those were the signs of strength.

Life did not lead me to become a cowboy or a professional athlete, it lead me into the arenas of health, fitness and business.

The versions of displayed strength change in these environments, but in some ways they are similar.

Strength is embodied by:

  • capital raised
  • charts moving up and to the right
  • number of employees the company has on-boarded in the past year
  • trend lines of total revenue
  • monthly recurring revenue

What I have found in the business world is that many signs of strength are faked signals. I am not talking about fraud, although there is definitely cases of that too. I am talking about people putting out press releases, purchasing office spaces, getting media coverage and hiring new team members to give an impression that they are doing better then they really are.

In some ways it is the way the game is played. To recruit good talent, to attract investment capital and to give new customers confidence that you can fulfill your promises, you need to be perceived as bigger, stronger and more stable than you currently are.

One of the great things about starting and working with multiple health, fitness and coaching businesses is that I often get to see behind the customer’s mask. People come to me for running, but they also want friendship. They use our products to improve their health, yet they need a safe place to discuss their fears.

The biggest lesson I have learned over my 18 year career thus far is that everyone has something they are trying to work through. This is true regardless of a client’s social, financial, health or career status.

It took me a long time to observe this reality. It took a lot longer for me to realize that I didn’t have to be a perfect example of health, fitness and well-being to beneficial for my clients. I actually did not learn this until after I had stopped personal training.

Gaining strength by being vulnerable.

Lewis Howes talks about the nine masks that men hide behind in his book, The Masks of Masculinity. These masks include: The stoic mask, the athlete mask, the material mask, the sexual mask, the aggressive mask, the joker mask, the invincible mask, the ‘know-it-all’ mask and the alpha mask.

I have used each of these masks at some point, however I have been most comfortable behind the stoic, athlete and ‘know-it-all’ masks.

These are personal discoveries I started having several years ago. Through these discoveries and within time of self-reflection, I realized that the pressure of living with those masks was overwhelming.

What do you do when you want people to believe something about yourself, but you know inside it is not the way you truly feel?

I made the decision to become more vulnerable. To be more open about how I truly felt. I decided to share my fears and disregard the advice that said ‘keep your feelings to yourself’.

I have learned to say “I have no idea” and “I do not know” to more questions than I have the answer to.

Taking the step to be more vulnerable was not exceptionally easy, however it also was not unique. Individuals like Brene Brown have given power to the concept of being vulnerable. The start-up world has more and more individuals stepping forward and being open about their struggles. I am optimistic that the athletic world will also see more changes.

There have been three outcomes of becoming more vulnerable:

1. I have become stronger and more resilent. When you do not have to keep living out a narrative that is not true, it frees you to be authentic and actually proceed in real strength.

2. Individuals respond to my vulnerability by observing some of the same issues within themselves and feel empowered to speak to me.

3. People are made uncomfortable by the vulnerability and we ignore the discussion.

A tangible outcome of those observations was combining the lessons with my knowledge in coaching, health and behavior change to create the Happier and Healthier You program.

A final thought.

I am a competitive person. The arena of competition continues to change, but when I am focused, I want to win. The cowboy persona, football icons and successful business leaders all instilled in me that you should never show weakness. However, I have learned that I am much stronger when I can share my vulnerabilities and still possess the courage to take my fears head-on.

This strength allows me to be a better person, friend, business partner, lover, athlete and community member.