score:1
here is an example of your reducer with explicit types:
interface iarticles {
articles: string[];
}
const initialstate: iarticles = {
articles: []
};
export interface useraction {
type: string;
payload: string;
}
const rootreducer = (state = initialstate, action: useraction): iarticles => {
switch (action.type) {
case "add_article": {
return {
articles: [action.payload, ...state.articles]
};
}
default:
return state;
}
};
previously i have expirienced same issue as you are, because types in reducer being wrong.
Source: stackoverflow.com
Related Query
- TypeScript CRA with Redux setup
- TypeScript struggles with Redux containers
- Redux Thunk with Typescript
- Typescript CRA with MSW: failed to parse source map
- Typing redux forms v7 with TypeScript and React
- How to use HOC with redux compose and Typescript
- Connecting a component with OwnProps using react redux and typescript in the .NET Core 2.0 reactredux template project
- React lazy with TypeScript and Redux
- Yarn 3.x PNP typescript CRA eslint not working with VSCode
- React observable epic with Redux Toolkit and Typescript
- Dispatching a Redux Thunk action outside of a React component with TypeScript
- react create app, typescript unit test with mocha and chai what is the correct setup to support es6 modules?
- react, redux with typescript error: Type '{}' is missing the following properties from type 'IProps': email, token
- Typescript integration with complex redux actions and reducers
- Easy setup react redux with next.js (React)
- import & export may only appear at the top level - CRA React App with Typescript
- Property does not exist on type error with Union Types in Typescript Reac + Redux
- Redux reducer initial state with Typescript
- error at react redux combinereducer with typescript
- createAsyncThunk redux toolkit with typescript rejecWithValue and Payload types error
- react redux reducer typescript error with combineReducers function
- React Redux connect is not assignable to type '() => void' with typescript
- React Redux Typescript error with AnyAction when implementing Redux-Persist
- Problem setting up Redux with TypeScript when having multiple action payload types
- Typing Redux Store with Typescript
- React CRA with typescript not working with eslint
- How to setup a generic interface for the state when using React useReducer with typescript
- How do i prevent circular type reference in typescript with redux and connect when using mapState function?
- How to use TypeScript with React / Redux mergeProps
- Issue with setup and run Electron + React + Typescript + Webpack application
More Query from same tag
- Unable to target nth child of styled component
- "You may need an appropriate loader to handle this file type"
- nested State sync failed trying to build a dynamic list component
- React - update nested state (Class Component)
- The links do not render the components of ReactJS. The URL changes but the page does not?
- useSWR with data specific to an authenticated user
- SCRIPT1028: SCRIPT1028: Expected identifier, string or number edge
- Proxy to backend with default Next.js dev server
- Saving image._id in react
- mapStateToProps doesn't change state
- Fibonacci Counter in React.js
- Get separate lists based on object property
- How do I format a string based on certain delimeters in reactjs?
- How to use setInterval in react?
- Can I get a reference to jsx react component so I can I forceUpdate/rerender react component from the chrome developer console?
- react router dom history.replace is not re-render component if same URL
- Is there a way to have evenly sized ticks for recharts axis while keeping my max value?
- When exporting reactjs components as node modules to npm, do I include jsx or js
- Applying a single onChange to all input boxes
- Trouble display name property from axios fetched json object
- How to access to row if cell is clicked in React/Redux
- Reactjs shows only first record each time a modal pop up button is clicked
- React toggle style on mapped element on click
- async storage is not working when I reload the react-native app
- react-script: Transpiling Third party JSX files
- Returning a new set of array using map method
- HOC for JSX element - rendering jsx with wrapped element
- react native post form data with object and file in it using axios
- How to get previous url in react gatsby
- How to pass data down to a component property in React?