(engine: StandardEngine)
| 113 | }; |
| 114 | |
| 115 | function checkNoopEngine(engine: StandardEngine) { |
| 116 | // if no engine provided, we default to no-op, handy for tests |
| 117 | // however, print a warning in other envs |
| 118 | if (process.env.NODE_ENV !== "test") { |
| 119 | engine === noopEngine && |
| 120 | // eslint-disable-next-line no-console |
| 121 | console.warn( |
| 122 | __DEV__ |
| 123 | ? ` |
| 124 | Styletron has been switched to a no-op (test) mode. |
| 125 | |
| 126 | A Styletron styled component was rendered, but no Styletron engine instance was provided in React context. |
| 127 | |
| 128 | Did you forget to provide a Styletron engine instance to React context via using the Styletron provider component? |
| 129 | |
| 130 | Note: Providers and Consumers must come from the exact same React.createContext call to work. |
| 131 | If your app has multiple instances of the "styletron-react" package in your node_module tree, |
| 132 | your Provider may be coming from a different React.createContext call, which means the styled components |
| 133 | will not recieve the provided engine instance. This scenario can arise, for example, when using "npm link". |
| 134 | ` |
| 135 | : `Styletron Provider is not set up. Defaulting to no-op.`, |
| 136 | ); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | export function useStyletron(): [(style: StyleObject) => string] { |
| 141 | const styletronEngine: StandardEngine = React.useContext(StyletronContext); |
no outgoing calls
no test coverage detected