Skip to content

Export context for hooks support #76

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

Merged
merged 4 commits into from
Oct 1, 2019

Conversation

zalishchuk
Copy link
Contributor

Export ParallaxContext for useContext hook support.

@codecov-io
Copy link

codecov-io commented Sep 24, 2019

Codecov Report

Merging #76 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #76   +/-   ##
=======================================
  Coverage   91.27%   91.27%           
=======================================
  Files          26       26           
  Lines         298      298           
  Branches       47       47           
=======================================
  Hits          272      272           
  Misses         22       22           
  Partials        4        4

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bca9efe...2a702f6. Read the comment docs.

@zalishchuk
Copy link
Contributor Author

Also added a useController hook which exposes the parallaxController using React hooks.

Usage example:

import React, { useLayoutEffect } from 'react';
import { useController } from 'react-scroll-parallax';

const App = () => {
  const { parallaxController } = useController();

  useLayoutEffect(() => {
    const handler = () => parallaxController.update();
    window.addEventListener('load', handler);
    return () => window.removeEventListener('load', handler);
  }, [parallaxController]);

  return (
    <div>
      {'...'}
    </div>
  );
};

@zalishchuk
Copy link
Contributor Author

@jscottsmith any thoughts on this?

@jscottsmith
Copy link
Owner

Love it.

Can you update the README documenting this export. Your usage example would be good to add there too.

https://github.com/jscottsmith/react-scroll-parallax#parallax-controller-context

@zalishchuk
Copy link
Contributor Author

Updated the README, check it if everything is fine.

@zalishchuk
Copy link
Contributor Author

@jscottsmith ping ✋

@jscottsmith
Copy link
Owner

Looks good, I’ll get it merged and publish a new release tonight.

Thanks for the contribution!

@jscottsmith jscottsmith changed the base branch from master to develop October 1, 2019 04:47
@jscottsmith jscottsmith merged commit 2797719 into jscottsmith:develop Oct 1, 2019
@jscottsmith
Copy link
Owner

@zalishchuk published 2.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants