-
-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we have an example of how to use notistack in functional component? #205
Comments
Let me know if this is buggy @nilamsavani, so I can add it to the official redux example as well. |
The example looks solid, but I noticed that it doesn't use the If that's not intentional, I can fork and post an updated CodeSandbox because I'm already trying use Notistack with the new React Redux hooks. |
Thanks @wilsonj806. redux-example now uses hooks only. |
Looks good @iamhosseindhv! Just a small suggestion, but I think it's better to have the FunctionalNotifier store the displayed notifications like the below: const FunctionalNotifier = () => {
// React Redux hooks
const dispatch = useDispatch();
const notifications = useSelector(state => state.app.notifications);
// Store the displayed notifications in component state
const [displayed, setDisplayed] = useState([]);
const storeDisplayed = id => {
setDisplayed(prevDisplayed => [...prevDisplayed, id]);
};
const removeDisplayed = id => {
setDisplayed(prevDisplayed => [...prevDisplayed.filter(key => id !== key)]);
};
// doMoreStuffBelow()
} That way it's clearer that Notifier tracks and updates displayed notifications. |
Hi,
I want to do the exact thing as done in https://codesandbox.io/s/github/iamhosseindhv/notistack/tree/master/examples/redux-example but I am using functional component.
Can anyone here create an example which has same functionality using the functional component?
The text was updated successfully, but these errors were encountered: