Author: Chris Lattner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import SystemConfiguration.CaptiveNetwork | |
| func getWiFiSsid() -> String? { | |
| var ssid: String? | |
| if let interfaces = CNCopySupportedInterfaces() as NSArray? { | |
| for interface in interfaces { | |
| if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? { | |
| ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Darwin | |
| @dynamicMemberLookup | |
| struct Environment { | |
| subscript(dynamicMember name: String) -> String? { | |
| get { | |
| guard let value = getenv(name) else { return nil } | |
| return String(validatingUTF8: value) | |
| } |
If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.
You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.
If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.
function MyComponent() {