eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 110 forks source link

Use React.ComponenType type instead of React.FC type for modal #49

Closed armandabric closed 2 years ago

armandabric commented 2 years ago

This change allow to use ClassComponent as modal. The React.ComponentType is an union between ComponentClass and FunctionComponent:

type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
codecov-commenter commented 2 years ago

Codecov Report

Merging #49 (fbf2443) into main (f9722ca) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #49   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          184       184           
  Branches        29        29           
=========================================
  Hits           184       184           
Impacted Files Coverage Δ
src/index.tsx 100.00% <100.00%> (ø)

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 f9722ca...fbf2443. Read the comment docs.

supnate commented 2 years ago

Hi @armandabric , since it always needs to use useModal hook in the modal component to control the state, so we limit the component type to functional component. If you want to use class component, you need to wrap your class component to a functional one with hoc pattern.