-
Notifications
You must be signed in to change notification settings - Fork 50
Add generic prop type support #152
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
4575b33
to
c8bbd41
Compare
@jamesrweb Great job and thanks for the quick responses! I've tested locally with the new changes and it seems to be working as intended. You might want to consider updating Here's an example that I used for my Next.js typescript project. import dynamic from 'next/dynamic';
import type { P5WrapperProps } from 'react-p5-wrapper';
interface YourSketchProps {
backgroundColor: string;
}
const ReactP5Wrapper = dynamic<P5WrapperProps<YourSketchProps>>(
() => import('react-p5-wrapper').then((mod) => mod.ReactP5Wrapper),
{
ssr: false,
}
);
const sketch: Sketch<YourSketchProps> = (p5) => {
// ...
p5.updateWithProps = (props) => {
backgroundColor = props.backgroundColor; // typed
// ...
};
}
// ...
<ReactP5Wrapper
sketch={sketch}
backgroundColor="rgb(255, 255, 255)" // typed
/> |
b744a75
to
c94ed78
Compare
Good point about the documentation, I will update this tomorrow also, thanks for that one, good catch! |
@jamesrweb are you going to add the documentation in the current PR? there are also conflicts, could you resolve them? |
I've re-tested, it seems like the only changes that needed to be made to my previous code was import type { P5WrapperProps, SketchProps } from 'react-p5-wrapper';
interface YourSketchProps extends SketchProps {
backgroundColor: string;
} And everything worked the same as before. |
I will add them to this PR as soon as I can. 👏🏻 |
@junwen-k Excellent! once the documentation is updated then we can get this merged then. 🚀 If there's any issues otherwise just let me know. I'll update the documentation ASAP otherwise 😇. |
c94ed78
to
fa6a299
Compare
fa6a299
to
028911a
Compare
@junwen-k @yevdyko I updated the documentation and resolved the conflicts, please take another look and approve if you are confident that: a) There isn't a breaking change being introduced Thanks in advance and fingers crossed we are almost there now with this feature 🎉! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR LGTM :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesrweb The documentation looks great, the changes are also good. I tried your examples in the typescript demo app and everything works as expected. I would say that it's ready to be released!
Thanks for this significant improvement 💪
🚢 🚢 🚢
Fixes issue #151
Proposed Changes
Additional notes
Please test this thoroughly with and without generics as this is a potentially breaking change and we want to be sure it is not!
Please also wait for review from @junwen-k so that he can verify the topic is resolved or needs further work / coverage.