Reusable Functions
Calling toi(Confirm) every time you need a confirmation works, but repeating the same component reference at every call site is easy to get wrong. toi.fn binds a component to toi once, returning a function you can call as many times as needed:
Each call to confirm() mounts a fresh instance of Confirm and returns a new promise, exactly like calling toi(Confirm) directly would.
Default props
If Confirm needs props beyond ref and resolve, pass a second argument to toi.fn to set defaults used whenever the returned function is called without its own props. Try both buttons below — the first uses the default message, the second overrides it:
Passing props to a call merges it with defaultProps — keys in props take precedence, and any defaultProps keys it doesn't include are still used.
See Additional Props for how the required-versus-optional shape of Props affects whether an argument can be omitted at all.