How to send data from a child component to its sibling?
I want create an app with two forms, each form in its own component. Users type in form 1, then the data will be passed to component 2. In there it will join the data of what they type in form 2. How can I do this?
Below is the code on my machine, taken from the answer from the same question in Stack Overflow. It works when using React on Stackblitz but I don't get why it's not in my machine:
index.jsx
Context.js
Form1.jsx
Form2.jsx
The app compiles fine, but the actual result is empty.Stack Overflow
How to send data from a child component to its sibling?
I want create an app with two forms, each form in its own component. Users type in form 1, then the data will be passed to component 2. In there it will join the data of what they type in form 2. H...
5 Replies
In your Form2 component, the line <p>The value is {form1Data} + {form2Data}</p> is not joining the two values properly. Try using curly braces and the + sign outside the string to link the values. See if this works <p>The value is {form1Data + ' ' + form2Data}</p>
still not working
besides that, do you think the code should work?
The concept is valid, but Fresh might need another data structure to make it work. I might take a look at it later on.
GitHub
unable to use preact context in fresh · Issue #983 · denoland/fresh
I managed to use preactcreateContext hook as the following: hooks/ShoppingCartProvider.tsx export const ShoppingCartContext = createContext({} as ShoppingCart); [...] return ( <ShoppingCartConte...
I think this is relevant