How to use button on customized edge to update state? #4186
Replies: 1 comment 12 replies
-
Doesn't look like you're using the context correctly, you might wanna re-check the React docs for Context =) You wanna start off with creating the context, which you did, so that part is fine, although a context should be capitalized like After having created the context and setting up the provider you need to use the context. const level = useContext(LevelContext);
// now you can use the provided value from `LevelContext`
console.log(level) // logs 1 Of course you don't need to use a context for this use-case, you could
{
id: 'e1-2',
source: '1',
target: '2',
data: {
doSomething: () => { /* ... */ }
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Community!
I created a graph using React Flow with a button on each edge. I customized both the edge and node to fit my requirements. However, I have questions about how to pass the data from customized edges or nodes to the file where the reactflow tag is located. For example, I want to update a specific state that is in the same file with the react flow tag. I tried useContext hook as below, but it seems not working. I guess it's because the customized edges are not wrapped in tag where I placed my Context Provider. Are there any way to solve this situation? Thank you.
Customized Edge
File where React FLow located
Beta Was this translation helpful? Give feedback.
All reactions