![]() ![]() ![]() The function gets executed by Remix, but you can access the results by calling the useLoaderData function. The loader function is specifically called for GET verbs on routes and it’s used to get data from a particular source (i.e reading from disk, querying a database, etc).These functions receive multiple parameters, including the HTTP request and the URLs params and payloads. And that is where Loaders and Actions come into play.īoth are functions that if you export them, the handler will execute before its actual code. And the handler function can be easily defined as:įor static content, the above code snippet is fantastic, but if you’re looking to create a web application, you’ll need some dynamic behavior. So, creating the file myroute.jsx inside app/routes you’ll make sure that the route works. And to define the right handler function, all you have to remember, is to export it as a default export. While the concept of a route is not new in any web framework really, the definition of one begins in Remix by creating the file that will contain its handler function.Īs long as you define the file inside the right folder, the framework will automatically create the route for you. You’ll be building components, using hyperscript to write your markup while at the same time, defining route handlers for the back-end section of your business logic. Yes, you’re using JavaScript for everything, with a very React-ish flavor to your code. I call it “full-stack framework” because it lets you code for the front-end and the back-end at the same time. Remix is a brand new full-stack framework for developing web applications.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |