How to force React (functional component using hooks) to create a new component from scratch on props change?Can you force a React component to rerender without calling setState?Updating Child Component Via Change of Props from Parent in Reactstateless component doesn't receive new props after actionReact - changing key prop doesn't cause rerender of child componentHow do react hooks determine the component that they are for?How to prevent child component from re-rendering when using React hooks and memo?Passing an array of Components as a Props in ReactWhat is the 'proper' way to update a react component after an interval with hooks?React hooks function component prevent re-render on state updateReact not passing props to component

What is this symbol: semicircles facing each other?

How to prevent clipped screen edges on my TV, HDMI-connected?

Algorithms vs LP or MIP

Heyacrazy: Careening

“T” in subscript in formulas

LeetCode: Group Anagrams C#

Immutable builder and updater

Is there any example of one country devastating a third?

Are there languages that inflect adverbs for gender

Transposing from C to Cm?

Nothing like a good ol' game of ModTen

Is it possible to generate a leveled character in borderlands 2?

Why is there so little discussion / research on the philosophy of precision?

Handwriting Music

Why isn't "I've" a proper response?

A discontinuity in an integral

Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?

Pythagorean triple with hypotenuse a power of 2

How to find out the average duration of the peer-review process for a given journal?

If all stars rotate, why was there a theory developed that requires non-rotating stars?

Was there ever a treaty between 2 entities with significantly different translations to the detriment of one party?

Antonym of "billable"

"Sorry to bother you" in an email?

Why are non-collision-resistant hash functions considered insecure for signing self-generated information



How to force React (functional component using hooks) to create a new component from scratch on props change?


Can you force a React component to rerender without calling setState?Updating Child Component Via Change of Props from Parent in Reactstateless component doesn't receive new props after actionReact - changing key prop doesn't cause rerender of child componentHow do react hooks determine the component that they are for?How to prevent child component from re-rendering when using React hooks and memo?Passing an array of Components as a Props in ReactWhat is the 'proper' way to update a react component after an interval with hooks?React hooks function component prevent re-render on state updateReact not passing props to component






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















TLDR



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



EDIT



The key attribute DOES work. The problem I was having was due to the state update sequence that I was doing. The first update was trying immediately to render a component that needed the last update to be already done.




I'm working on a component called <AddProductWidget>, that will get the following props about a product and need to display its details. It belongs to a page with a search bar that you fill the productID and it gets the product details from a cloud function.



It's rendered like this:



 <AddProductWidget
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


AddProductWidget.js



It renders a <UserImages> component that lets the user clicks on some images to select before saving to the database. So it needed a state to 'remember' which images have been clicked by the user.



function AddProductWidget(props) 

const [userImagesSelected, setUserImagesSelected] = useState(
() =>
if (props.userImages && props.userImages > 0)
return new Array(props.userImages.length).fill(false);

return null;

);

// IT renders the <UserImages> component
// The code here is simplified

return(
<UserImages
userImages=props.userImages
userImagesSelected=userImagesSelected
setUserImagesSelected=setUserImagesSelected
/>
);




The initial state of that array userImagesSelected should be the same length of the userImages array and be filled with false values, that will become true once the user start clicking on the images. If the product doesn't have user images, props.userImages will be null and userImagesSelected should also be null.



Everything is working as expected when I load the first product. Whether it has images or not, everything is being displayed correctly.



The problem:



The problem is when I load a product with zero images, and subsequentely I load another product with 5 images, for example. Basically the props for AddProductWidget will change (since it received a new product), but because React seems to be trying to use the same component instance, I get an error, because my UserImages component will try to render the selected images information, but the state of userImagesSelected will still be null, because the last products had no images.



When I was working with classes, I could force React to recreate a component instance using the key attribute, but that doesn't seem to work with hooks, since the following code didn't solve my problem:



 <AddProductWidget
key=productID
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


Question



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



Extra



A found a way around it, but it seems a bit hacky, even though it's on React docs. It basically uses a state to detect when props change and calls setState() during render. I would like it better to recreate my component from scratch.



Hooks FAQ: How do I implement getDerivedStateFromProps










share|improve this question


























  • what makes you think the key is not working? a new key would make the component un-mount and mount again

    – Sagiv b.g
    Mar 27 at 18:13











  • I tried that bit of code and it didn't work. Should it work with a functional component using hooks? I'll give it another try and will let you know.

    – cbdev420
    Mar 27 at 18:21











  • Just retried and confirmed that it doesn't work.

    – cbdev420
    Mar 27 at 18:27











  • A small and concise run-able example would help

    – Sagiv b.g
    Mar 27 at 18:32











  • Working on it! Thanks!

    – cbdev420
    Mar 27 at 18:45

















2















TLDR



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



EDIT



The key attribute DOES work. The problem I was having was due to the state update sequence that I was doing. The first update was trying immediately to render a component that needed the last update to be already done.




I'm working on a component called <AddProductWidget>, that will get the following props about a product and need to display its details. It belongs to a page with a search bar that you fill the productID and it gets the product details from a cloud function.



It's rendered like this:



 <AddProductWidget
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


AddProductWidget.js



It renders a <UserImages> component that lets the user clicks on some images to select before saving to the database. So it needed a state to 'remember' which images have been clicked by the user.



function AddProductWidget(props) 

const [userImagesSelected, setUserImagesSelected] = useState(
() =>
if (props.userImages && props.userImages > 0)
return new Array(props.userImages.length).fill(false);

return null;

);

// IT renders the <UserImages> component
// The code here is simplified

return(
<UserImages
userImages=props.userImages
userImagesSelected=userImagesSelected
setUserImagesSelected=setUserImagesSelected
/>
);




The initial state of that array userImagesSelected should be the same length of the userImages array and be filled with false values, that will become true once the user start clicking on the images. If the product doesn't have user images, props.userImages will be null and userImagesSelected should also be null.



Everything is working as expected when I load the first product. Whether it has images or not, everything is being displayed correctly.



The problem:



The problem is when I load a product with zero images, and subsequentely I load another product with 5 images, for example. Basically the props for AddProductWidget will change (since it received a new product), but because React seems to be trying to use the same component instance, I get an error, because my UserImages component will try to render the selected images information, but the state of userImagesSelected will still be null, because the last products had no images.



When I was working with classes, I could force React to recreate a component instance using the key attribute, but that doesn't seem to work with hooks, since the following code didn't solve my problem:



 <AddProductWidget
key=productID
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


Question



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



Extra



A found a way around it, but it seems a bit hacky, even though it's on React docs. It basically uses a state to detect when props change and calls setState() during render. I would like it better to recreate my component from scratch.



Hooks FAQ: How do I implement getDerivedStateFromProps










share|improve this question


























  • what makes you think the key is not working? a new key would make the component un-mount and mount again

    – Sagiv b.g
    Mar 27 at 18:13











  • I tried that bit of code and it didn't work. Should it work with a functional component using hooks? I'll give it another try and will let you know.

    – cbdev420
    Mar 27 at 18:21











  • Just retried and confirmed that it doesn't work.

    – cbdev420
    Mar 27 at 18:27











  • A small and concise run-able example would help

    – Sagiv b.g
    Mar 27 at 18:32











  • Working on it! Thanks!

    – cbdev420
    Mar 27 at 18:45













2












2








2








TLDR



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



EDIT



The key attribute DOES work. The problem I was having was due to the state update sequence that I was doing. The first update was trying immediately to render a component that needed the last update to be already done.




I'm working on a component called <AddProductWidget>, that will get the following props about a product and need to display its details. It belongs to a page with a search bar that you fill the productID and it gets the product details from a cloud function.



It's rendered like this:



 <AddProductWidget
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


AddProductWidget.js



It renders a <UserImages> component that lets the user clicks on some images to select before saving to the database. So it needed a state to 'remember' which images have been clicked by the user.



function AddProductWidget(props) 

const [userImagesSelected, setUserImagesSelected] = useState(
() =>
if (props.userImages && props.userImages > 0)
return new Array(props.userImages.length).fill(false);

return null;

);

// IT renders the <UserImages> component
// The code here is simplified

return(
<UserImages
userImages=props.userImages
userImagesSelected=userImagesSelected
setUserImagesSelected=setUserImagesSelected
/>
);




The initial state of that array userImagesSelected should be the same length of the userImages array and be filled with false values, that will become true once the user start clicking on the images. If the product doesn't have user images, props.userImages will be null and userImagesSelected should also be null.



Everything is working as expected when I load the first product. Whether it has images or not, everything is being displayed correctly.



The problem:



The problem is when I load a product with zero images, and subsequentely I load another product with 5 images, for example. Basically the props for AddProductWidget will change (since it received a new product), but because React seems to be trying to use the same component instance, I get an error, because my UserImages component will try to render the selected images information, but the state of userImagesSelected will still be null, because the last products had no images.



When I was working with classes, I could force React to recreate a component instance using the key attribute, but that doesn't seem to work with hooks, since the following code didn't solve my problem:



 <AddProductWidget
key=productID
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


Question



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



Extra



A found a way around it, but it seems a bit hacky, even though it's on React docs. It basically uses a state to detect when props change and calls setState() during render. I would like it better to recreate my component from scratch.



Hooks FAQ: How do I implement getDerivedStateFromProps










share|improve this question
















TLDR



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



EDIT



The key attribute DOES work. The problem I was having was due to the state update sequence that I was doing. The first update was trying immediately to render a component that needed the last update to be already done.




I'm working on a component called <AddProductWidget>, that will get the following props about a product and need to display its details. It belongs to a page with a search bar that you fill the productID and it gets the product details from a cloud function.



It's rendered like this:



 <AddProductWidget
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


AddProductWidget.js



It renders a <UserImages> component that lets the user clicks on some images to select before saving to the database. So it needed a state to 'remember' which images have been clicked by the user.



function AddProductWidget(props) 

const [userImagesSelected, setUserImagesSelected] = useState(
() =>
if (props.userImages && props.userImages > 0)
return new Array(props.userImages.length).fill(false);

return null;

);

// IT renders the <UserImages> component
// The code here is simplified

return(
<UserImages
userImages=props.userImages
userImagesSelected=userImagesSelected
setUserImagesSelected=setUserImagesSelected
/>
);




The initial state of that array userImagesSelected should be the same length of the userImages array and be filled with false values, that will become true once the user start clicking on the images. If the product doesn't have user images, props.userImages will be null and userImagesSelected should also be null.



Everything is working as expected when I load the first product. Whether it has images or not, everything is being displayed correctly.



The problem:



The problem is when I load a product with zero images, and subsequentely I load another product with 5 images, for example. Basically the props for AddProductWidget will change (since it received a new product), but because React seems to be trying to use the same component instance, I get an error, because my UserImages component will try to render the selected images information, but the state of userImagesSelected will still be null, because the last products had no images.



When I was working with classes, I could force React to recreate a component instance using the key attribute, but that doesn't seem to work with hooks, since the following code didn't solve my problem:



 <AddProductWidget
key=productID
userImages=props.productDetails.userImages // Array of strings (urls)
title=props.productDetails.title
stars=props.productDetails.stars
/>


Question



Is there a way to force React to recreate a component (functional component using hooks) from scratch instead of re-rendering it on a prop change?



Extra



A found a way around it, but it seems a bit hacky, even though it's on React docs. It basically uses a state to detect when props change and calls setState() during render. I would like it better to recreate my component from scratch.



Hooks FAQ: How do I implement getDerivedStateFromProps







reactjs react-hooks






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 19:44







cbdev420

















asked Mar 27 at 17:31









cbdev420cbdev420

2,3878 silver badges29 bronze badges




2,3878 silver badges29 bronze badges















  • what makes you think the key is not working? a new key would make the component un-mount and mount again

    – Sagiv b.g
    Mar 27 at 18:13











  • I tried that bit of code and it didn't work. Should it work with a functional component using hooks? I'll give it another try and will let you know.

    – cbdev420
    Mar 27 at 18:21











  • Just retried and confirmed that it doesn't work.

    – cbdev420
    Mar 27 at 18:27











  • A small and concise run-able example would help

    – Sagiv b.g
    Mar 27 at 18:32











  • Working on it! Thanks!

    – cbdev420
    Mar 27 at 18:45

















  • what makes you think the key is not working? a new key would make the component un-mount and mount again

    – Sagiv b.g
    Mar 27 at 18:13











  • I tried that bit of code and it didn't work. Should it work with a functional component using hooks? I'll give it another try and will let you know.

    – cbdev420
    Mar 27 at 18:21











  • Just retried and confirmed that it doesn't work.

    – cbdev420
    Mar 27 at 18:27











  • A small and concise run-able example would help

    – Sagiv b.g
    Mar 27 at 18:32











  • Working on it! Thanks!

    – cbdev420
    Mar 27 at 18:45
















what makes you think the key is not working? a new key would make the component un-mount and mount again

– Sagiv b.g
Mar 27 at 18:13





what makes you think the key is not working? a new key would make the component un-mount and mount again

– Sagiv b.g
Mar 27 at 18:13













I tried that bit of code and it didn't work. Should it work with a functional component using hooks? I'll give it another try and will let you know.

– cbdev420
Mar 27 at 18:21





I tried that bit of code and it didn't work. Should it work with a functional component using hooks? I'll give it another try and will let you know.

– cbdev420
Mar 27 at 18:21













Just retried and confirmed that it doesn't work.

– cbdev420
Mar 27 at 18:27





Just retried and confirmed that it doesn't work.

– cbdev420
Mar 27 at 18:27













A small and concise run-able example would help

– Sagiv b.g
Mar 27 at 18:32





A small and concise run-able example would help

– Sagiv b.g
Mar 27 at 18:32













Working on it! Thanks!

– cbdev420
Mar 27 at 18:45





Working on it! Thanks!

– cbdev420
Mar 27 at 18:45












1 Answer
1






active

oldest

votes


















2















Not sure how you decided that a different key won't re-mount the component but it should do that (are you sure the key has changed?)



Here is a running example showing this






function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />








share|improve this answer



























  • You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

    – cbdev420
    Mar 27 at 19:13






  • 1





    Yup the entire tree

    – Sagiv b.g
    Mar 27 at 19:19






  • 1





    It should work. I got to debug my code. Thanks!

    – cbdev420
    Mar 27 at 19:24










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383320%2fhow-to-force-react-functional-component-using-hooks-to-create-a-new-component%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2















Not sure how you decided that a different key won't re-mount the component but it should do that (are you sure the key has changed?)



Here is a running example showing this






function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />








share|improve this answer



























  • You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

    – cbdev420
    Mar 27 at 19:13






  • 1





    Yup the entire tree

    – Sagiv b.g
    Mar 27 at 19:19






  • 1





    It should work. I got to debug my code. Thanks!

    – cbdev420
    Mar 27 at 19:24















2















Not sure how you decided that a different key won't re-mount the component but it should do that (are you sure the key has changed?)



Here is a running example showing this






function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />








share|improve this answer



























  • You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

    – cbdev420
    Mar 27 at 19:13






  • 1





    Yup the entire tree

    – Sagiv b.g
    Mar 27 at 19:19






  • 1





    It should work. I got to debug my code. Thanks!

    – cbdev420
    Mar 27 at 19:24













2














2










2









Not sure how you decided that a different key won't re-mount the component but it should do that (are you sure the key has changed?)



Here is a running example showing this






function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />








share|improve this answer















Not sure how you decided that a different key won't re-mount the component but it should do that (are you sure the key has changed?)



Here is a running example showing this






function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />








function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />





function Test() 
React.useEffect(() =>
console.log('Test was mounted');
return () =>
console.log('Test was un-mounted');
;
, []);

return "hi there, I'm Test";


function App()
const [val, setVal] = React.useState("Change me...");
return (
<div className="App">
<input value=val onChange=e => setVal(e.target.value) />
<br />
<Test key=val />
</div>
);


const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="root" />






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 27 at 19:55

























answered Mar 27 at 18:50









Sagiv b.gSagiv b.g

19.5k6 gold badges30 silver badges65 bronze badges




19.5k6 gold badges30 silver badges65 bronze badges















  • You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

    – cbdev420
    Mar 27 at 19:13






  • 1





    Yup the entire tree

    – Sagiv b.g
    Mar 27 at 19:19






  • 1





    It should work. I got to debug my code. Thanks!

    – cbdev420
    Mar 27 at 19:24

















  • You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

    – cbdev420
    Mar 27 at 19:13






  • 1





    Yup the entire tree

    – Sagiv b.g
    Mar 27 at 19:19






  • 1





    It should work. I got to debug my code. Thanks!

    – cbdev420
    Mar 27 at 19:24
















You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

– cbdev420
Mar 27 at 19:13





You are correct! The key should be working. I've also managed to get it working on the example that I was building. I got some bug on my code. Do you know if when it re-mounts the parent, does it automatically remount its children as well?

– cbdev420
Mar 27 at 19:13




1




1





Yup the entire tree

– Sagiv b.g
Mar 27 at 19:19





Yup the entire tree

– Sagiv b.g
Mar 27 at 19:19




1




1





It should work. I got to debug my code. Thanks!

– cbdev420
Mar 27 at 19:24





It should work. I got to debug my code. Thanks!

– cbdev420
Mar 27 at 19:24








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383320%2fhow-to-force-react-functional-component-using-hooks-to-create-a-new-component%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript