Hi everyone! This is my first react typescript projects. Any suggestions are highly appreciated. Thanks.
Pontus Östlund
@poppaAll comments
- @jhunxeinSubmitted over 3 years ago@poppaPosted over 3 years ago
Nice job.
In a real-world situation it would probably be preferable to create separate components for your input and button in the FormEmail component.
To get better use of TS you can create your functional components like this:
// The return type of MyComponent will be inferred via React.FC // `children` are always part of the FC props and known to TS export const MyComponent: React.FC = ({ children }) => { // Component code }
And in the case your component takes props:
interface MyComponentProps { name: string // Required prop email?: string // Optional prop age?: number // Optional prop } // The return type and prop-types will be inferred via React.FC export const MyComponent: React.FC<MyComponentProps> = ({ name, email, age }) => { // We know `name` MUST be set // `email` and `age` might be `undefined` }
Happy coding!
0 - @brandonmharringtonSubmitted over 3 years ago
Could anyone explain to me why the site works locally but doesn't work once hosted to GH Pages? I have noticed others' solutions have the same effect. Does it have to do with the API Key? I see CORS request did not succeed in the console when the page loads and it tries to get the client's IP Address.
@poppaPosted over 3 years agoIt seems to work when I visit the site, but there are shit loads of warning from the map since the map tiles are loaded over HTTP while the site is served over HTTPS. (Mixed content warning)
Just change the line https://github.com/brandonmharrington/ip-address-tracker/blob/d70c6b56755bc7b4821cb83fa267086304f4938e/script.js#L78 to use the HTTPS version to solve that.
0