Skip to content

Instantly share code, notes, and snippets.

@muslemomar
Created December 10, 2022 13:09
Show Gist options
  • Save muslemomar/7383376bf331938ca8e268b88cd65f2e to your computer and use it in GitHub Desktop.
Save muslemomar/7383376bf331938ca8e268b88cd65f2e to your computer and use it in GitHub Desktop.
  1. What are the similarities between context, redux, and local state?
  2. What is the difference between an action and an action creator in Redux?
  3. In your own words, what problem does context and Redux aim to solve?
  4. Please fill out the following table.
Tool When should we use this over the others?
Context
Redux
Local state

.5 Which of these should you prefer to use the most and why? Please give more than a one sentence answer.

@Hala-AlArid
Copy link

Aland, Marshall, Hala, Huda

  1. They are all used to store and manage data
  2. Actions are payloads of information that send data from your application to your store. while
    action creator is a function that returns an action
  3. the problem of passing down the state to only the components that need it, instead of having to drill it as props.
  4. context: when we have static data with less frequency of repetition
    redux: when we have dynamic data with lots of repetitions
    local state: when we have one (or few) components that can share the same data
  5. Redux since it is much more powerful and provides a set of handy features that Context doesn't have.

@RageOfKurd
Copy link

Names : Nina Hawari , Noor rihda , Fadi Moayed , Roza Nawzad , Hevar Tofiq

1- they all used to manage state of our datas inside the application
2- An action is an object that has two fields a type, and a payload. An action creator is a function, that just creates and returns an action
3- they both solve the lifecycle of state in our application from two main points : props drilling and state lifting
4-
context: it's better to be used with datas that have low frequency of change in the app such as theme state
Redux: better to be used with datas with high frequency of change like api data
local state: better to be used when we don't nest components that the deepest components does not depend on the parent components for the state props.

5- basically Redux because it's more optimized and it already built on context of react and solves the headache of using local state.

@Amal95Salah
Copy link

Team Member : Amal, Dalia, Shahla and Zeynab
Q1: Managing the state, state transformations and storage for data.
Q2: Action is message that we send to redux store. It can be of any type like mostly object which contain payload and action type
Action creator is function which create and return function dynamically.
Q3: The problem is passing the data through many components to reach child component.
Context and Redux solved the problem by passing the data to child component directly.
Q4:
Context: Recommended when pass static data that changes less frequently.
Redux: Is optimized for dynamic data that changes frequently. It is passed down through global storage.
Local State: It is passed down props and it should be passed through all the parents of the child component.

@sudo-riham
Copy link

  1. Redux and context both of them libraries that managing and updating data storage in a global way so that all components can use it and there's no need to pass the props to each child components.
  2. An action is simply an object that has two things: a type, and a payload. An action creator is simply a function, that just returns an action
  3. Props Drilling,
  4. ->Redux is optimized for dynamic data
    ->context api is for static data(that changes less frequently)
    ->Local storage - was introduced to store strings size upto 10MB and is mainly used to store cache files, site data etc
  5. It depends on the stituation because every library is unique because like for example if we had a situation that we had a lot amount of golbal data and props it'll be better to use redux and if had just a few amounts of props that we want to apply it's better to use context cause we don't have to install a lot of packages in this situation.

Team: Rokaya, Danah, Nanor, Riham

@BaraaNazar
Copy link

BaraaNazar commented Dec 10, 2022

team: baraa , ali ibrahim, Nisreen, yahya and Ramyar

  1. all are used to manage the state of a specific component.
  2. An action is a plain JavaScript object that is sent to the Redux store to update the state tree. An action creator is a function that creates and returns an action. The action creator usually takes some parameters that it uses to construct the action before dispatching it.
  3. Redux is used to easily connect your components and select those parts of the state that they need. So, communication between components becomes much easier, instead of passing callbacks to props. Context provides a way to share/pass data between components without having to explicitly pass a prop through every level of the tree.
  4. context: for static data that doesn't change frequently and small projects, Redux: for responsive and large projects. Local state is useful when you need to manage state within a single component and don't need to share that state with other components in your application. It can help keep your components modular and easy to understand, and can make it easier to manage the overall state of your application.
  5. redux can be used small and big projects.

@daryanaji
Copy link

daryanaji commented Dec 10, 2022

Heyam, Maryam, Darya

1- They are uses for storing data in React apps.

2- We communicate with the redux store using an action. It can be of any type, but often it is an object with a payload and an action type. Action creator is a function that dynamically creates and returns functions.

3- To solve the prop drilling issue.

4-
-Context :If some values are needed on different levels of the components tree and for many elements and if you want to avoid passing down props, it will be a good idea to use context for this data.
-Redux used when you have large amounts of application state that are needed in many places in the app .
-Local state:If we're dealing with data that other parts of the application don't care about.

@Mhamad6000
Copy link

mhamad othman , banel mikhael , shad mustafa , batoul el mansur , ahmad hassoun
1- all of them are for saving data inside variable
2- An action is simply an object that has two things: a type, and a payload. An action creator is simply a function, that just returns an action.
3- both redux and context aim to solve state management , redux is much faster for complex applications .
4- we should use context for small projects and if we have small amount of states , redux is for complex projects and when You have large amounts of application state that are needed in many places in the app we use redux .
5- redux because its faster and used in most companies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment