Pass function callback as props to scenes
See original GitHub issueHello, it’s me again. One question, how do we pass function type props to scenes? I am doing something like this:
const stateNavigator = new StateNavigator([
{key: 'sceneA', trackCrumbTrail: true},
{key: 'sceneB', trackCrumbTrail: true},
]);
const {sceneA, sceneB} = stateNavigator.states;
sceneA.renderScene = () => <Foo />;
sceneB.renderScene = ({callback}) => <Bar />;
stateNavigator.navigate("sceneB", {
callback: () => {
// change something
}
})
However, the value for callback
in sceneB.renderScene
is undefined.
It seems function type variable is erased from navigationData
when encoding data to routeInfo and decoding it back from routeInfo?
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (21 by maintainers)
Top Results From Across the Web
React: Pass a Callback as Props
This is how you allow child components to interact with their parent components. You pass methods to a child just like a regular...
Read more >Passing Functions to Components
Pass event handlers and other functions as props to child components: ... and it is often the easiest way to pass parameters to...
Read more >Passing callback functions to child components, is not a ...
I get the error _videos.filteredVideo) is not a function when I try and dispatch an action from a child component. How can I...
Read more >Callback functions in React
Passing props down to the child is also part of that process, but what gets passed is a bit different. Instead of passing...
Read more >How to pass a parameter to an event handler or callback
Example 2: In this example, we will use the arrow function to create a new function that calls the function call with the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So you can pass a function as long as you pass it to render scene. Great thanks for the help!!!
You don’t have to use context. You can pass the function as a prop.