score:1
you can wrap the function in useselector
into createselector
from reselect
which will memoise the selector values. you can do it like this:
import react, { useeffect } from "react";
import { createselector } from "reselect";
import { usedispatch, useselector } from "react-redux";
import { searchpersonaction } from "./store";
const memoiseselector = createselector(
(s) => s.name,
(name) => name
);
const search = () => {
const dispatch = usedispatch();
const name = useselector(memoiseselector);
const search = (e) => {
const txt = e.target.value;
dispatch(searchpersonaction(txt));
};
return (
<div>
<input onchange={search} placeholder="search" />
<ul>
{name?.map((p) => (
<li key={p.name}>{p.name}</li>
))}
</ul>
</div>
);
};
export default search;
further more examples you can check here on official docs.
Source: stackoverflow.com
Related Query
- Integrate reselect in redux
- How to integrate Reselect in my React + Redux application?
- How does Redux Reselect memoization work?
- Redux State Using Reselect To Derive Related Data
- redux reselect is returning a function
- How to integrate redux with antd form validation
- redux reselect selectors for relational data
- React Redux Reselect - Undefined State
- Implementing reselect in redux prevents new changes to appear instantly
- Add a selector using reselect in redux
- Can we use Reselect memoization with redux for every single selector (even the silmplest getters)?
- next js with redux and reselect
- Filtering comments with Redux Reselect
- integrate react semantic ui checkbox with redux form
- How to integrate React Rating w Redux Form
- React - Redux - Integrate Firebase Database in my App
- How to integrate sagaMiddleWare.run(RootSaga) into a redux storeFactory
- Trying to integrate redux into react application. Webpack is choking on store.js
- how to filter through an array and check if a nested object includes a value of true using reselect in redux
- How to integrate .css and .js with ReactJS + Redux architecture?
- How to integrate loading screen on route change with redux in Next.js
- How to use redux reselect avoiding redundancy
- reselect object from redux
- Integrate redux form with react tag autocomplete
- React / Redux / Reselect - is mapped state to props using selectors synchronous or asynchronous?
- How to integrate Firebaseui auth with Redux
- React Typescript Redux-Toolkit - integrate redux state with existing ES2015 Classses based React Component
- @twilio/flex-webchat-ui how to integrate in my react redux project
- Why use Redux over Facebook Flux?
- What is the best way to access redux store outside a react component?
More Query from same tag
- How do you conditionally apply multiple classes to a single Material UI classes prop
- React - activeclass on root page
- React Test Utils - Spy not called when a simulated click is performed -
- React server not starting - something with renderProps
- Recursively adding and removing values from javascript object
- React Query - fire function once when all requests have been finished
- need help getting props to work using react
- gatsby-plugin-dark-mode causing type error. Typescript Gatsby
- Show loading spinner
- Promises in redux-saga
- How to change input value when click on another input box in React
- How to autofocus redux field
- icons are not showing after clicking close
- How to restructure object from another object in javascript
- Update a field of an object in a list
- Axios createError.js:16 Uncaught (in promise) Error: Request failed with status code 400
- Clean Create React App's cache when importing graphql files
- react-select focus() doesn't show cursor after change
- Render a table with a json array in Reactjs
- How to render different classes on span using React.js?
- How do I show a of list elements of an array?
- How to add a form to meteor and react application
- React router passing id via params
- React Router - Content Security Policy directive: "default-src 'self'
- How to reset the timer using UseEffect React Hooks
- redux-form (version 6.4.3) does not display errors
- Sort by category doesn't work in React Component
- Override an @media for material-ui react componentd doesn't work
- sheet js xlsx writeFile callback
- React component not rendering after checking for Authentication