id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
reducers_and_actions_urls_rtk_query/part-5-async-logic5_63_0.txt | You can chain these together, like `
builder.addCase().addCase().addMatcher().addDefaultCase() ` . If multiple
matchers match the action, they will run in the order they were defined.
import { increment } from '../features/counter/counterSlice'
const postsSlice = createSlice({
name: ... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_15_0.txt | The project also includes a small HTTP API client object that exposes `
client.get() ` and ` client.post() ` methods, similar to popular HTTP
libraries like ` axios ` . It's defined in ` src/api/client.js ` .
We'll use the ` client ` object to make HTTP calls to our in-memory fake REST
API for this section. | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_91_0.txt | We've got one more set of topics to cover the core Redux Toolkit APIs and
usage patterns. In Part 6: Performance and Normalizing Data , we'll look at
how Redux usage affects React performance, and some ways we can optimize our
application for improved performance.
Edit this page | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_65_0.txt | We'll handle all three action types that could be dispatched by the thunk,
based on the ` Promise ` we returned:
* When the request starts, we'll set the ` status ` enum to ` 'loading' `
* If the request succeeds, we mark the ` status ` as ` 'succeeded' ` , and add the fetched posts to ` state.posts `
* If the r... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_15_0.txt | 1. We import the createSlice & createAsyncThunk API from Redux Toolkit to create the slice of state for the posts coming from the API and createAsyncThunk to handle the asynchronous requests to and from the API. The axios package is to deal with the HTTP get and post requests effortlessly.
2. Create an i... | |
reducers_and_actions_urls_rtk_query/6151153_36_0.txt | Yes I know this game and I got your point.
sherif71180 June 19, 2023, 5:50am 14 | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_69_0.txt |
import { Spinner } from '../../components/Spinner'
import { PostAuthor } from './PostAuthor'
import { TimeAgo } from './TimeAgo'
import { ReactionButtons } from './ReactionButtons'
import { selectAllPosts, fetchPosts } from './postsSlice'
const PostExcerpt = ({ post })... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_13_0.txt | ## Parameters
` createAsyncThunk ` accepts three parameters: a string action ` type ` value,
a ` payloadCreator ` callback, and an ` options ` object. | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_22_0.txt | ## Consuming State/Data on the Frontend
import { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { getPosts } from '../features/posts/postsSlice'
const PostsList = () => {
const dispatch = useDispatch()
// Get the posts from the st... | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_0_8.txt | state.entities[payload.id] = payload
})
builder.addCase(updateUser.rejected, (state, action) => {
if (action.payload) {
// Being that we passed in ValidationErrors to rejectType in `createAsyncThunk`, the payload will be available here.
state.error = act... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_90_0.txt | * You can write reusable "selector" functions to encapsulate reading values from the Redux state
* Selectors are functions that get the Redux ` state ` as an argument, and return some data
* Redux uses plugins called "middleware" to enable async logic
* The standard async middleware is called ` redux-thu... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_50_0.txt | * If it was cancelled before execution, ` meta.condition ` will be true.
* If it was aborted while running, ` meta.aborted ` will be true.
* If neither of those is true, the thunk was not cancelled, it was simply rejected, either by a Promise rejection or ` rejectWithValue ` .
* If the thunk was not rejected... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_19_0.txt |
// Pull in configureStore API
import { configureStore } from '@reduxjs/toolkit';
// Pull in the postsSlice reducer and rename it to postsReducer
import postsReducer from '../features/posts/postsSlice';
// Create the Redux store and pass in the postsReducer as the initial dat... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_46_0.txt | ### Reading the Signal Value
You can use the ` signal.aborted ` property to regularly check if the thunk
has been aborted and in that case stop costly long-running work: | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_92_0.txt | Last updated on Nov 15, 2023
Previous | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_2_2.txt | actions
.addMatcher(isActionWithNumberPayload, (state, action) => {})
// and provide a default case if no other handlers matched
.addDefaultCase((state, action) => {})
}
)
import { createAction, createReducer } from '@reduxjs/toolkit'
... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_31_0.txt |
// in the component
const onClick = () => {
dispatch(fetchUserById(userId))
.unwrap()
.then((originalPromiseResult) => {
// handle result here
})
.catch((rejectedValueOrSerializedError) => {
// handle error here
... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_21_0.txt | We can see from the logic above, to create the Redux store, that it is the
configureStore API imported from the Redux Toolkit that is bringing
everything together. The reducer we exported from postsSlice.js is now
imported and renamed as postsReducer . One of the great things about the
configureStore API is that it... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_93_0.txt | Using Redux Data
Next | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_52_0.txt | * Home
* Podcasts
* Videos
* Tags
* DEV Help
* Forem Shop
* Advertise on DEV
* DEV Showcase
* About
* Contact
* Guides
* Software comparisons
* Code of Conduct
* Privacy Policy
* Terms of use | |
reducers_and_actions_urls_rtk_query/6151153_15_0.txt | ### Proxying API Requests in Development | Create React App
Note: this feature is available with react-scripts@0.2.3 and higher. | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_53_0.txt | * Using rejectWithValue to access a custom rejected payload in a component
Note: this is a contrived example assuming our userAPI only ever throws
validation-specific errors | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_8_0.txt | On this page
# ` createAsyncThunk ` | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_10_0.txt | * Familiarity with using AJAX requests to fetch and update data from a server
## Introduction | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_29_0.txt | Thunks may return a value when dispatched. A common use case is to return a
promise from the thunk, dispatch the thunk from a component, and then wait for
the promise to resolve before doing additional work:
const onClick = () => {
dispatch(fetchUserById(userId)).then(() => {
// do addi... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_21_0.txt | ` createAsyncThunk ` returns a standard Redux thunk action creator. The thunk
action creator function will have plain action creators for the ` pending ` ,
` fulfilled ` , and ` rejected ` cases attached as nested fields.
Using the ` fetchUserById ` example above, ` createAsyncThunk ` will generate
four functions: | |
reducers_and_actions_urls_rtk_query/6151153_33_0.txt | 1 Like
sherif71180 June 11, 2023, 8:25pm 12 | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_37_0.txt | Confirm
For further actions, you may consider blocking this person and/or reporting
abuse | |
reducers_and_actions_urls_rtk_query/6151153_11_0.txt | ### createSlice | Redux Toolkit
sherif71180 June 10, 2023, 10:15pm 3 | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_35_0.txt | In order to do that, we're going to have to change the structure of the state
in our ` postsSlice ` , so that we can keep track of the current state of the
API request.
### Extracting Posts Selectors | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_7_0.txt | Share Post via... Report Abuse
Adekola Olawale | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_48_0.txt | You can also call ` signal.addEventListener('abort', callback) ` to have logic
inside the thunk be notified when ` promise.abort() ` was called. This can for
example be used in conjunction with an axios ` CancelToken ` :
import { createAsyncThunk } from '@reduxjs/toolkit'
import axios from 'axios' ... | |
reducers_and_actions_urls_rtk_query/6151153_23_0.txt | 1 Like
sherif71180 June 11, 2023, 5:05pm 9 | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_17_0.txt | As a reminder, the code examples focus on the key concepts and changes for
each section. See the CodeSandbox projects and the ` tutorial-steps ` branch
in the project repo for the complete changes in the application.
## Thunks and Async Logic | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_55_0.txt | Previous
createSlice | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_3_3.txt | nter: { value: 2 } }), // 2
)
caution
The ` Proxy ` retrieves a reducer's initial state by calling it with a
randomly generated action type - don't try to handle this as a special case
inside your reducer.
#### Nested combined reducer
The wrapped selector expects to use the state returned by the co... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_30_0.txt | The thunks generated by ` createAsyncThunk ` will always return a resolved
promise with either the ` fulfilled ` action object or ` rejected ` action
object inside, as appropriate.
The calling logic may wish to treat these actions as if they were the original
promise contents. The promise returned by the dispatched t... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_32_0.txt | PS: You can find the complete code here: https://github.com/Kola92/redux-
toolkit-tutorial
## Top comments (0) | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_53_0.txt | Built on Forem — the open source software that powers DEV and other
inclusive communities.
Made with love and Ruby on Rails . DEV Community © 2016 - 2024. | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_14_0.txt | Enter fullscreen mode Exit fullscreen mode
From the contents of the postSlice.js file above, you can see a lot is going
on there, so I will break it down in detailed steps (also pay attention to the
comments above each line of code). | |
reducers_and_actions_urls_rtk_query/rtk_query_0_0.txt | Skip to main content
[   **Redux
Toolkit** ](/)
[ Getting Started ](/introduction/getting-started) [ Tutorials
](/tutorials/overview) [ Usage Guide ](/usage/usage-guide) [ API
](/api/configureStore) [ RTK Query ](/rtk-query/overview) [ GitHub
](https://github.... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_28_0.txt | Thunks may have async logic inside of them, such as ` setTimeout ` , ` Promise
` s, and ` async/await ` . This makes them a good place to put AJAX calls to a
server API.
Data fetching logic for Redux typically follows a predictable pattern: | |
reducers_and_actions_urls_rtk_query/6151153_41_0.txt | Thank you so much lasjorg. My greetings for you
system Closed December 28, 2023, 3:33am 17 | |
reducers_and_actions_urls_rtk_query/6151153_17_0.txt | sherif71180 June 11, 2023, 10:59am 5
No, I am not using proxies.
Here are my package.json for react-app: | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_44_0.txt | * Location
Abuja, Nigeria | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_2_0.txt | * Introduction
* Tutorials | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_26_0.txt |
const reducer1 = createReducer(initialState, (builder) => {
builder.addCase(fetchUserById.fulfilled, (state, action) => {})
})
const reducer2 = createSlice({
name: 'users',
initialState,
reducers: {},
extraReducers: (builder) => {
builde... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_24_0.txt | Before the arrival of the useSelector and useDispatch hooks in 2019, the
connect() method was used instead to wrap components that need the state/data
coming from the Redux store. mapStateToProps and mapDispatchToProps
functions were initially fulfilling the functions of useSelector and
useDispatch respectiv... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_47_0.txt | We can use this information to decide what to show in our UI as the request
progresses, and also add logic in our reducers to prevent cases like loading
data twice.
Let's update our ` postsSlice ` to use this pattern to track loading state for
a "fetch posts" request. We'll switch our state from being an array of post... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_41_0.txt | vidvatek - Apr 25
### Introducing DIVZ - a React component to scroll, swipe & zoom through
content on the 3D z-axis | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_98_0.txt | Copyright © 2015–2024 Dan Abramov and the Redux documentation authors.
| |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_11_0.txt | tip
Redux Toolkit's RTK Query data fetching API is a purpose built data fetching
and caching solution for Redux apps, and can eliminate the need to write any
thunks or reducers to manage data fetching . We encourage you to try it out
and see if it can help simplify the data fetching code in your own apps! | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_3_4.txt | Redux documentation authors.
| |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_44_0.txt | Additionally, your ` payloadCreator ` can use the ` AbortSignal ` it is passed
via ` thunkAPI.signal ` to actually cancel a costly asynchronous action.
The ` fetch ` api of modern browsers already comes with support for an `
AbortSignal ` : | |
reducers_and_actions_urls_rtk_query/6151153_8_0.txt | and finally my server as server.js :
const express = require("express");
const cors = require("cors");
const app = express();
app.use(cors());
app.use(express.json());
app.post("api/users", (request,response) => {
setTimeout(function() {
response.send(re... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_72_0.txt | We're now fetching and displaying our list of posts. But, if we look at the
posts, there's a problem: they all now say "Unknown author" as the authors:
This is because the post entries are being randomly generated by the fake API
server, which also randomly generates a set of fake users every time we reload
the page. ... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_44_0.txt | ### Loading State for Requests
When we make an API call, we can view its progress as a small state machine
that can be in one of four possible states: | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_39_0.txt | Note that the ` state ` parameter for these selector functions is the root
Redux state object, as it was for the inlined anonymous selectors we wrote
directly inside of ` useSelector ` .
We can then use them in the components: | |
reducers_and_actions_urls_rtk_query/6151153_1_0.txt | JavaScript
sherif71180 June 10, 2023, 12:43pm 1 | |
reducers_and_actions_urls_rtk_query/6151153_7_0.txt | 5. store.js
import { configureStore } from "@reduxjs/toolkit";
import userSlice from "./userSlice";
const store = configureStore({
reducer: {
user: userSlice,
},
});
export default store;
| |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_36_0.txt | ## Handling Thunk Errors
When your ` payloadCreator ` returns a rejected promise (such as a thrown
error in an ` async ` function), the thunk will dispatch a ` rejected ` action
containing an automatically-serialized version of the error as ` action.error
` . However, to ensure serializability, everything that doe... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_32_0.txt | However, writing code using this approach is tedious. Each separate type of
request needs repeated similar implementation:
* Unique action types need to be defined for the three different cases
* Each of those action types usually has a corresponding action creator function
* A thunk has to be written that dis... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_9_0.txt | * How to use the Redux "thunk" middleware for async logic
* Patterns for handling async request state
* How to use the Redux Toolkit ` createAsyncThunk ` API to simplify async calls
Prerequisites | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_47_0.txt | * Joined
Mar 3, 2018 | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_52_0.txt | ` createAsyncThunk ` accepts two arguments:
* A string that will be used as the prefix for the generated action types
* A "payload creator" callback function that should return a ` Promise ` containing some data, or a rejected ` Promise ` with an error | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_17_0.txt | The ` payloadCreator ` function can contain whatever logic you need to
calculate an appropriate result. This could include a standard AJAX data fetch
request, multiple AJAX calls with the results combined into a final value,
interactions with React Native ` AsyncStorage ` , and so on.
The ` payloadCreator ` function w... | |
reducers_and_actions_urls_rtk_query/rtk_query_2_7.txt | seGetPostQuery(id, { skip: !id })
return <div>...</div>
}
While you might be able to convince yourself that the query won't be called
unless the ` id ` arg is a ` number ` at the time, TypeScript won't be
convinced so easily.
RTK Query provides a ` skipToken ` export which can be used as a... | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_0_6.txt | while (!done) {
if (signal.aborted) {
throw new Error('stop the work, this has been aborted!')
}
const read = await reader.read()
result += read.value
done = read.done
}
return result
},
)
#### Li... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_48_0.txt | ### More from Adekola Olawale
Firebase Authentication: Build a Smooth Authentication Flow System with
Firebase | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_80_0.txt | We can use ` createAsyncThunk ` to help with sending data, not just fetching
it. We'll create a thunk that accepts the values from our ` <AddPostForm> ` as
an argument, and makes an HTTP POST call to the fake API to save the data.
In the process, we're going to change how we work with the new post object in
our reduce... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_42_0.txt | features/posts/EditPostForm.js
// omit imports
import { postUpdated, selectPostById } from './postsSlice'
export const EditPostForm = ({ match }) => {
const { postId } = match.params
const post = useSelector(state => selectPostById(state, postId))
// omit... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_84_0.txt | features/posts/AddPostForm.js
import React, { useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { addNewPost } from './postsSlice'
export const AddPostForm = () => {
const [title, setTitle] = useState('')
const [content, ... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_81_0.txt | features/posts/postsSlice.js
export const addNewPost = createAsyncThunk(
'posts/addNewPost',
// The payload creator receives the partial `{title, content, user}` object
async initialPost => {
// We send the initial data to the fake API server
const response = a... | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_0_5.txt | ould be canceled, the ` condition ` callback should return a
literal ` false ` value or a promise that should resolve to ` false ` . If a
promise is returned, the thunk waits for it to get fulfilled before
dispatching the ` pending ` action, otherwise it proceeds with dispatching
synchronously.
const fet... | |
reducers_and_actions_urls_rtk_query/6151153_34_0.txt | I filled up the inputs and submitted, but the state returned empty.
sherif71180 June 11, 2023, 8:26pm 13 | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_47_0.txt |
import { createAsyncThunk } from '@reduxjs/toolkit'
const readStream = createAsyncThunk(
'readStream',
async (stream: ReadableStream, { signal }) => {
const reader = stream.getReader()
let done = false
let result = ''
while... | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_4_0.txt | * Usage Guide
* Usage With TypeScript
* Writing Reducers with Immer
* Setup with Next.js
* API Reference
* Store Setup | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_20_0.txt | In any web application that handles state management with Redux, without the
Redux store there is nothing that can be achieved with Redux. It is the same
as building an application without using Redux. The Redux store is what ties
in everything together and it’s from the store that the UI can pull data via
the reducers... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_23_0.txt | Enter fullscreen mode Exit fullscreen mode
Implementing the data/state coming from the store we will need to import a
couple of packages. The useSelector hook aid in selecting the specific
data/state we need from the store instead of pulling everything including the
ones we don’t need. This ensures our application ... | |
reducers_and_actions_urls_rtk_query/using-redux-toolkit-to-handle-asynchronous-data-requests-54om0_0_0.txt | Skip to content
Navigation menu | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_96_0.txt | Community
* Reactiflux Discord
* Stack Overflow
* Feedback | |
reducers_and_actions_urls_rtk_query/createAsyncThunk3_7_0.txt | * API Reference
* * API Reference
* Reducers and Actions
* createAsyncThunk | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_4_8.txt | 'redux'
const incrementBy = createAction<number>('incrementBy')
const decrementBy = createAction<number>('decrementBy')
const counter = createSlice({
name: 'counter',
initialState: 0 satisfies number as number,
reducers: {
increment: (state) => state + ... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_20_0.txt | The most common reason to use middleware is to allow different kinds of async
logic to interact with the store . This allows you to write code that can
dispatch actions and check the store state, while keeping that logic separate
from your UI.
There are many kinds of async middleware for Redux, and each lets you writ... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_7_0.txt | * * Tutorials
* Redux Essentials
* Async Logic and Data Fetching
On this page | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_0_0.txt | Skip to main content
[   **Redux
Toolkit** ](/)
[ Getting Started ](/introduction/getting-started) [ Tutorials
](/tutorials/overview) [ Usage Guide ](/usage/usage-guide) [ API
](/api/configureStore) [ RTK Query ](/rtk-query/overview) [ GitHub
](https://github.... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_41_0.txt | features/posts/SinglePostPage.js
// omit imports
import { selectPostById } from './postsSlice'
export const SinglePostPage = ({ match }) => {
const { postId } = match.params
const post = useSelector(state => selectPostById(state, postId))
// omit componen... | |
reducers_and_actions_urls_rtk_query/reducers_and_actions_0_4.txt | re
})
}
Or with async/await syntax:
// in the component
const onClick = async () => {
try {
const originalPromiseResult = await dispatch(fetchUserById(userId)).unwrap()
// handle result here
} catch (rejectedValueOrSerializedError) ... | |
reducers_and_actions_urls_rtk_query/rtk_query_2_3.txt | mResponse`
// v
transformResponse: (rawResult: { result: { post: Post } }, meta) => {
// ^
// The optional `meta` property is available based on the type for the `baseQuery` used
... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_74_0.txt |
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'
import { client } from '../../api/client'
const initialState = []
export const fetchUsers = createAsyncThunk('users/fetchUsers', async () => {
const response = await client.get('/fakeApi/users')
... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_82_0.txt | ### Checking Thunk Results in Components
Finally, we'll update ` <AddPostForm> ` to dispatch the ` addNewPost ` thunk
instead of the old ` postAdded ` action. Since this is another API call to the
server, it will take some time and could fail. The ` addNewPost() ` thunk
will automatically dispatch its ` pending/... | |
reducers_and_actions_urls_rtk_query/part-5-async-logic5_43_0.txt | It's often a good idea to encapsulate data lookups by writing reusable
selectors. You can also create "memoized" selectors that can help improve
performance, which we'll look at in a later part of this tutorial.
But, like any abstraction, it's not something you should do all the time,
everywhere. Writing selectors m... | |
flask_documentation/python3flaskinteract_126_0.txt |
Enter fullscreen mode Exit fullscreen mode | |
flask_documentation/howtodockerizeyourfl_13_0.txt | [ Follow
](/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fsubscribe%2Fuser%2Ff3e3395e9bbf&operation=register&redirect=https%3A%2F%2Fmedium.com%2Fgeekculture%2Fhow-
to-dockerize-your-flask-
application-2d0487ecefb8&user=Dinesh+Kumar+K+B&userId=f3e3395e9bbf&source=post_page-f3e3395e9bbf
----2d0487ecefb8--------------... | |
flask_documentation/dockerfaskapi_33_0.txt | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 | |
flask_documentation/howtodockerizeaflask_15_0.txt | A **docker container** is a collection of dependencies and code organized as
software that enables applications to run quickly and efficiently in a range
of computing environments. | |
flask_documentation/python3flaskinteract_106_0.txt |
@app.route("/upload", methods=["POST"])
def upload_file():
f = request.files["file"] | |
flask_documentation/howtodockerizeaflask_60_0.txt | docker build --tag python-docker . | |
flask_documentation/python3flaskinteract_83_0.txt | RUN pip install pipenv
RUN pipenv install | |
flask_documentation/dockerfaskapi_122_0.txt | ### Hello Jekyll! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.