Meteorologist Dashboard

A web application for a meteorologist's dashboard uses a Redux store to manage temperature data. The Redux store is configured with the Redux toolkit where the latest temperature data is fetched using the Redux thunk function.

Below is the code for the store's configuration:

const weatherURL = "http://example.com/temperaturejson";

const fetchTemperature = createAsyncThunk(
  "weather/fetchTemperature",
  async (arg, thunkAPI) => {
    const response = await fetch(weatherURL);
    return response.json();
  }
);

const temperatureSlice = createSlice({
  name: "temperature",
  initialState: { temperature: 0 },
  reducers: {},
  extraReducers: (builder) => {
    builder.addCase(fetchTemperature.fulfilled, (state, action) => {
      state.temperature = action.payload.temperature;
    });
    builder.addCase(fetchTemperature.pending, (state, action) => {
      state.temperature = "loading";
    });
    builder.addCase(fetchTemperature.rejected, (state, action) => {
      console.log(action);
      state.temperature = "unavailable";
    });
  },
});

const weatherStore = configureStore({ reducer: temperatureSlice.reducer });

What is true about the behavior of weatherStore?

(Select all acceptable answers.)

Tags

  • Redux Toolkit
  • Redux Store
  • Thunk
  • New
  • Public
  • Easy

Information

Difficulty: Easy

Duration: 5 min

Author: Siddharth N A

Score Distribution

Not enough data for chart.

Would you like to see our other questions?

We have 1000+ premium hand-crafted questions for 160+ job skills and 20+ coding languages. We prefer questions with small samples of actual work over academic problems or brain teasers.

Would you like to see our tests?

The following tests contain Redux Toolkit related questions:

On the blog

Since we're all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they've been screening people for many years, so they must know how to do it right?

Not really. I was surprised to discover that many experts...