Updating State With componentDidUpdate() and React-APlayer Library

Asked
Active3 hr before
Viewed126 times

8 Answers

updatingstatereact
90%

Are you sure componentDidUpdate is being called, can you log before your if statement and before you call setState and see if either/both are logged – steff_bdh Apr 22 '20 at 17:37 ,And here is the react-aplayer component from that library that is called:,I am trying to update the state with data received from a fetch request in the parent component. I am using the ‘react-aplayer’ library (https://github.com/MoePlayer/react-aplayer) as an audio player.

Pretag
 Pretag team - issue, fix, solve, resolve
88%

The React library allows teams to work faster and with more consistency. In this article, Camilo Reyes explains how to get started using React components in a C# application. ,For example, say there’s a prop to reset state in the component:,The modulus operator allows the news item to iterate as the index increases.

Pretag
 Pretag team - issue, fix, solve, resolve
72%

I added the componentDidUpdate() lifecycle method and compared State:,I added a component to my app that enabled a user to search and retrieve data for a particular Home Health Care Provider.,To update the data based on the user input required the use of componentDidUpdate, seems relatively straightforward. However I made a simple mistake — huge thank you to Spencer Carli, (who offers code review consulting, in addition to creating fabulous courses) for helping identify and correct the issue.

Because I was only comparing State to prevState, I did not set up to include prevProps as a parameter. It worked, the search returned the data as expected — I only caught the issue due to getting into the habit of using console.log when creating / adding data return methods. The console.log showed that I was hitting my API multiple times per second. Spencer identified the issue within a minute or two — I needed to include prevProps as an included parameter.

componentDidUpdate(prevProps, prevState)
65%

Pretag
 Pretag team - issue, fix, solve, resolve
75%

Pretag
 Pretag team - issue, fix, solve, resolve
40%

The writing was over before I knew it, and we've sold way more copies than I expected! Plus, the compliments from my peers have been really amazing.",While many engineers work at startups or are interested in starting their own company, venture capital can seem like a total mystery. In this episode, we talk about how venture capital firms function, how VCs make money - and...,Learn web development from expert teachers. Build real projects, join our community, and accelerate your career

Pretag
 Pretag team - issue, fix, solve, resolve
22%

The final step to achieve playback is to instantiate your player on componentDidUpdate and provide it with your target URL:,From there, the Video.js player needs to be instantiated on componentDidMount before it is available for use:,Once the video tag is in place, rendering a video in HLS.js is as simple as updating our componentDidUpdate to attach the media:

Pretag
 Pretag team - issue, fix, solve, resolve
60%

Do we need this array on the state of the Game component?,Let’s simply place the array of numbers and the array of stars on the Game component instance.,Do we need a class component to represent this new Number component?

class Game extends React.Component {
  render() {
    return (
      <div className="game">
        <div className="help">
          Pick 1 or more numbers that sum
          to the number of stars
        </div>
        <div className="body">
          <div className="stars">
            <div className="star" />
           {/* Repeat element random X times */}
          </div>
          <div className="play-numbers">
            <button className="number">1</button>
            {/* Numbers 1 to 9 */}
          </div>
        </div>
      </div>
    );
  }
}

ReactDOM.render(<Game />, mountNode);
load more v

Other "updating-state" queries related to "Updating State With componentDidUpdate() and React-APlayer Library"