reactivesearch icon indicating copy to clipboard operation
reactivesearch copied to clipboard

Possible to stop RemoveComponent?

Open dres-cifuentes opened this issue 7 years ago • 2 comments

Issue Type: Enhancement

Platform: Native

Description: Hello! So I've managed to create custom search components, while making it happen on a separate screen I called "Filters" connected through React Navigation. I'm using the ReactiveBase component at a root level so that I can go back and forth between my Results screen and Filters screen.

Here's the problem: Navigating away from the custom components unmounts it. Since I'm using ReactiveComponent to build my custom comps, it has a feature where whenever componentWillUnmount happens, removeComponent is invoked. Essentially my filters are being cleared as I navigate back to the results screen.

componentWillUnmount() {
		this.props.removeComponent(this.props.componentId);

		if (this.internalComponent) {
			this.props.removeComponent(this.internalComponent);
		}
	}

Would love to solve this without forking and making my own changes to ReactiveComponent

Thanks!

Screenshots:

Minimal reproduction of the problem with instructions:

Reactivesearch version: x.y.z 0.12.0

Browser: IOS

Anything else:

dres-cifuentes avatar Apr 10 '19 17:04 dres-cifuentes

@dres-cifuentes can you try achieving this by global state / redux store? Example with each change you store query and value in your state and when component remounts if you have query and value the you can set it via setQuery prop.

lakhansamani avatar Apr 12 '19 09:04 lakhansamani

I started going down that route but got a different recommendation.

I installed a package named "react-native-drawer" which gives me the animation I need, I can set the offset to 0 so the drawer takes up the entire screen, and it doesn't unmount!

Now to get SelectedFilters working properly with my custom components :)

Thanks for your recommendation!

dres-cifuentes avatar Apr 16 '19 13:04 dres-cifuentes