Comments (7)
what version of react do you use?
from why-did-you-render.
16.8.6
.
from why-did-you-render.
how "TakeNotes " looks like?
from why-did-you-render.
import React, {
useMemo,
useState,
useEffect,
useRef,
useCallback
} from "react";
import * as utils from "src/shared/utils";
import ChartData from "./data";
import useSlipper from "@dp-ui/utils/dist/useSlipper";
import useRedux from "@dp-ui/utils/dist/redux-hooks";
import { fetchHome } from "../Home/home.redux";
import { Layout, Container } from "./styles";
import safeGet from "@dp-ui/utils/dist/safeGet";
import { Icon } from "antd";
const TakeNotes = props => {
const onSubmitHomeNavigator = useCallback((): void => {
props.history.push("/");
}, []);
const { bigNumber, vCompare } = useMemo(
() => utils.calculateData(ChartData.data),
[]
);
const [notes, setNotes] = useState("");
const [submitFlag, setSubmitFlag] = useState(false);
const notesRef = useRef<HTMLUListElement>(null);
useSlipper(notesRef as React.MutableRefObject<HTMLUListElement>, {
handleSelector: "slider"
});
const notesChangeHandler = text => {
setNotes(text);
};
const prepareData = (mappedPropsData: any[]): any[] => {
const data =
mappedPropsData.filter(curr => {
return curr.id === parseInt(props.match.params.notesID);
})[0] || {};
return safeGet(data, "notes", []);
};
const mappedProps = useRedux<any, any, any, {}>(s => s, { fetchHome });
useEffect(() => {
//action to load page data
if (!mappedProps.pins.payload) mappedProps.fetchHome();
safeGet(
mappedProps,
`mappedProps.pins.payload[${parseInt(props.match.params.notesID) ||
0}].notes`,
[]
);
// eslint-disable-next-line no-console
console.log("Mounted");
}, []);
return (
<React.Fragment>
<Layout className="layout">
<Container>
<div className="notesHeader">Take notes</div>
<div className="navigationHome" onClick={onSubmitHomeNavigator}>
DONE
</div>
<div className="notesArea" />
<div className="discountedHeadersGroup">
<div className="dailyTotalDiscountedOrders">
DAILY - TOTAL DISCOUNTED ORDERS
</div>
<div className="daily">DAILY</div>
</div>
<div className="progressGroup">
<div className="discountedOrderNumber">
{Math.round((bigNumber / 1000) * 100) / 100}K
</div>
<div className="percentageGroup">
<div
className={
vCompare > 0 ? "chart-progress-up" : "chart-progress-down"
}
>
{vCompare < 0 ? "▼" : "▲"}
</div>
<div
className={
vCompare > 0 ? "wowPercentage-up" : "wowPercentage-down"
}
>
{Math.round(vCompare * 100 * 100) / 100}% WOW
</div>
</div>
</div>
<div className="horzontalSeparator" />
<div className="inputBoxNotes">
<textarea
className="inputAreaNotes"
value={notes}
onChange={evt => notesChangeHandler(evt.target.value)}
maxLength={60}
placeholder="write a note..."
rows={6}
cols={40}
onFocus={() => setSubmitFlag(true)}
/>
<div className="textLength">{notes.length}/60</div>
</div>
{submitFlag && (
<div className="actionGroup">
<div
className="cancel"
onClick={() => {
notesChangeHandler("");
setSubmitFlag(false);
}}
>
<span className="cancelText">Cancel</span>
</div>
<div className="submit" onClick={() => null}>
<span className="submitText">Submit</span>
</div>
</div>
)}
<div className="previousNotes">Previous notes</div>
<div>
<Icon type="close" />
</div>
>
<ul className="notesList" ref={notesRef}>
{mappedProps.pins.payload &&
prepareData(mappedProps.pins.payload).map((curr, index) => {
return (
<li className="noteRow" key={index} id={`${index}`}>
<div className="parallelRow">
<div className="row">
<div className="deleteRow">X</div>
<div className="noteData">
<span className="noteTitle">{curr.text}</span>
<span className="noteTimestamp">
{`${utils.dateUtility(curr.updatedAt).day} ${
utils.dateUtility(curr.updatedAt).month
} | 3.7K weekly`}
</span>
</div>
<div className="slider">E</div>
</div>
<div className="eachNoteSeparator" />
</div>
</li>
);
})}
</ul>
</Container>
</Layout>
</React.Fragment>
);
};
TakeNotes.whyDidYouRender = true;
export default TakeNotes;
from why-did-you-render.
It's quite strange, why would React.useRef()
return an empty string instead of a ref object?
from why-did-you-render.
Please provide a sandbox with a reproduction of this issue.
I couldn't figure out how could this happen.
from why-did-you-render.
This issue would be reopened when more information is provided.
from why-did-you-render.
Related Issues (20)
- Issues with Parcel? HOT 3
- use React.lazy warp function, wdyr not work.
- Is it possible to print testID along side Component name on wdyr logs? HOT 1
- use jotai always diff
- dom npm
- wdyr not work in next13 (repo provided) HOT 2
- wdyr not work in next13 (repo provided)
- WDYR includes full lodash library with window._ override HOT 6
- Cannot get WDYR output from nextjs dynamically loaded component (e.g. for no-ssr use case) HOT 2
- Project still being actively maintained? HOT 2
- Multiple React roots
- why-did-you-render + React Query
- No logs or anything about WDYR HOT 9
- Missing `ownerDataMap` in `notifier`
- Partially Working with React 18 + NextJS 13
- "Support for defaultProps will be removed" error after setting include: [/./] option HOT 2
- Tracking custom hooks issue HOT 2
- WhyDidYouRender is not working in Storybook.js
- Property 'React' doesn't exist HOT 1
- react-refresh-webpack-plugin not updating component when wrapped with React.memo.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from why-did-you-render.