life cycle Method
note : life cycle method only used within class component
Cases of cycle method
-
Mounting : we use mounting methods when instance of component is being created and inserted into the dom
-
updating : we use updating methods when a component is being re-renderd as a resuilt of changes to either its props or state
we will describe the methids in the order of excution
-
constructore method: which is a metode that called when a new component is created to initialize a state
- render method: which read props and state and excute children component
- componentDidMount method: this method invoked immediatly when after the component and all its children component have been rendred
- react Updates method : these methods tregare when there is a change to eithere props or state
What types of things can you pass in the props?
Props (aka “properties”) in React allows us to pass values from a parent component down to a child component. The values can be any data type, from strings to functions, objects, etc. Components cannot change their props - this can only be done externally, as the parent component changes the values passed down
What is the big difference between props and state?
What is the big difference between props and state? in react js Basically, the difference is that state is something like attributes in OOP : it’s something local to a class (component), used to better describe it. Props are like parameters - they are passed to a component from the caller of a component (the parent) : as if you called a function with certain parameters
When do we re-render our application?
React components automatically re-render whenever there is a change in their state or props. A simple update of the state, from anywhere in the code, causes all the User Interface (UI) elements to be re-rendered automatically.
What are some examples of things that we could store in state?
Anything you can do in JavaScript, you can also do in React.