Questions tagged [react-functional-component]
Function components in React are plain JavaScript functions that are used as React components. They have access to component features via Hooks. Use this tag for questions regarding the usage or behavior of function components. Do not use this tag if the question just uses them, but doesn't specifically asks about them.
react-functional-component
1,309
questions
1
vote
1
answer
50
views
Converting and using a class component with functions to a functional component in React?
For context, I'm trying to make a project using the html canvas in React. I am trying to replace the class components with functional components for uniformity and avoiding mixing of class and ...
-1
votes
1
answer
35
views
How react functional component works? [duplicate]
Can someone explain the difference in calling a JSX Element as component and as function in react?
These are my functions.
Case-1: as a function
const MyFunction = () => {
return (
<div>...
0
votes
0
answers
54
views
React State Update Not Reflecting Immediately in Conditional Rendering
I am working on a React component where I need to select an item from a list and update the state with the selected item's ID. I then want to conditionally render the selected item. However, I am ...
1
vote
1
answer
37
views
Functions not using most recent state in React functional component
I am converting a class component to a functional component but I am having an issue where state values from useState are not the most recent values inside a another function. Because the functions ...
0
votes
0
answers
18
views
Getting value from Props before making API call [duplicate]
Hey so I'm trying to take a user's latitude and longitude and use that data in an API call to get accurate information.
I'm running into a problem where my API call is being sent before the State that ...
0
votes
1
answer
14
views
UNSAFE_componentWillReceiveProps(nextProps) in functional component
I have a class based component as below:
class NeedsApprovalEditTransactionInfoContainer extends React.Component {
UNSAFE_componentWillReceiveProps(nextProps) {
if (
nextProps....
0
votes
1
answer
23
views
labels customisation in line chart using highcharts
I am using line chart, where I have added plot bands ranges. I want to return those labels of y-axis which are present in plot bands.
labels: {
formatter: function () {
if ([-12, -10, 0.0, 6.5, 10, 20]...
1
vote
0
answers
75
views
How to implement a linkedlist using Typescript in a functional component in React?
I'm currently learning data structures on my own. Most websites provide an implementation using classes and I'm unable to find an implementation using functions for functional components.
I want to ...
0
votes
0
answers
29
views
How to calculate the median value in an async function in SPFx, React.JS and SPFx Chart.js Plugin
I want to create a scatter chart where the x value is the calculated median value from different SharePoint List fields. The x-axis is fixed. I have ratings from different persons for different ...
1
vote
1
answer
145
views
How to transform a class component to a functional component in SPFx React.js and get value from a SharePoint list
I have a written a class component in SPFx with the pnp/js framework and React.js. I need to transform it to a functional component in react. I'm struggeling to call my SharePoint lists now.
I have a ...
0
votes
1
answer
133
views
Is it possible to define a specific type for React Node children (and their props)?
If I have a functional component...
const MyParent = (props:MyParentProps)=>{
etc...
}
...is it possible in Typescript to define that all children must adhere to a specific type or interface? ...
1
vote
1
answer
59
views
How to redirect to specific route when first route is matched in react router-dom v6 [duplicate]
In my current application, there's a route like this: "http://localhost:3000/:productId/productInfo". The :productId part is dynamic, meaning it can be anything. Users are redirected to the ...
-1
votes
1
answer
71
views
Passing Props from a Functional component to a class component
I am doing a React tutorial and author has a playground where everything works. But in my IDE when I try to pass props to a class component, the component does not recognize the props. I have been at ...
0
votes
1
answer
124
views
How to test for uniqueness of value in array in Yup?
I have created a dynamic form with validation in React with Formik.
What I have achieved so far:
Current code allows users to selecting the number of tickets to purchase and then entering the name and ...
0
votes
0
answers
392
views
Uncaught TypeError: setImmediate is not a function
I am using a React TextEditor package React Draft Wysiwyg.
Here is the implementation.
export default function TextEditor() {
const [editorState, setEditorState] = useState(() =>
...